Make 'name' default to CallerArgumentExpression for convenience
This commit is contained in:
1 parent
66dc76b9ff
commit
2fb67bdb55
1 file changed
+1
-1
@@ -108,7 +108,7 @@ namespace mbts.utils {
|
||||
GreaterThanEqualTo(argument, value, name);
|
||||
}
|
||||
|
||||
public static void LessThan<T>(T argument, T value, string name) where T : IComparable<T> {
|
||||
public static void LessThan<T>(T argument, T value, [CallerArgumentExpression(nameof(argument))]string name = "") where T : IComparable<T> {
|
||||
if (argument.CompareTo(value) >= 0)
|
||||
throw new ArgumentException($"Must be less than {value}.", name);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user