Udostępnij za pośrednictwem


Throw.IfArgument(Boolean, String, String) Method

Definition

Throws ArgumentException with the given parameter name and optional message if the given Boolean value is true.

public static void IfArgument (bool isInvalid, string paramName, string message = default);
static member IfArgument : bool * string * string -> unit
Public Shared Sub IfArgument (isInvalid As Boolean, paramName As String, Optional message As String = Nothing)

Parameters

isInvalid
Boolean

The flag to test. This method throws if it's true and does nothing if it's false.

paramName
String

The name of the parameter being validated. This is passed to the ArgumentException constructor.

message
String

An optional error message to include in the ArgumentException. The default message is "Invalid argument."

Applies to