ThrowIfFalse Method
Definition
ThrowIfFalse(bool, string, string, string)
Validates and throws an ArgumentException if the specified condition is false.
public static void ThrowIfFalse(bool condition, string paramName, string message = "Value is not in a valid state.", string expression = null)
Parameters
conditionboolThe value to be evaluated.
paramNamestringThe name of the parameter that caused the exception.
messagestringA message that describes the error.
expressionstringThe
conditionexpressed as a string.
Exceptions
- ArgumentException
conditionisfalse.
ThrowIfFalse(Func<bool>, string, string, string)
Validates and throws an ArgumentException if the specified predicate returns false.
public static void ThrowIfFalse(Func<bool> predicate, string paramName, string message = "Value is not in a valid state.", string expression = null)
Parameters
predicateFunc<bool>The function delegate that determines if an ArgumentException is thrown.
paramNamestringThe name of the parameter that caused the exception.
messagestringA message that describes the error.
expressionstringThe
predicateexpressed as a string.
Exceptions
- ArgumentException
predicatereturnedfalse.