ArgumentException Class

Definition

The exception that is thrown when one of the arguments provided to a method is not valid.

[ComVisible(true)]
[Serializable]
public class ArgumentException : SystemException, _Exception, ISerializable
Inheritance
ArgumentException
Derived

Inherited Members

System.Exception

System.Object

Constructors

ArgumentException()

Initializes a new instance of the ArgumentException class.

public ArgumentException()

ArgumentException(String)

Initializes a new instance of the ArgumentException class with a specified error message.

public ArgumentException(string message)
Parameters
message
String

The error message that explains the reason for the exception.

ArgumentException(String, Exception)

Initializes a new instance of the ArgumentException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public ArgumentException(string message, Exception innerException)
Parameters
message
String

The error message that explains the reason for the exception.

innerException
Exception

The exception that is the cause of the current exception. If the innerException parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.

See Also

ArgumentException(String, String)

Initializes a new instance of the ArgumentException class with a specified error message and the name of the parameter that causes this exception.

public ArgumentException(string message, string paramName)
Parameters
message
String

The error message that explains the reason for the exception.

paramName
String

The name of the parameter that caused the current exception.

ArgumentException(String, String, Exception)

Initializes a new instance of the ArgumentException class with a specified error message, the parameter name, and a reference to the inner exception that is the cause of this exception.

public ArgumentException(string message, string paramName, Exception innerException)
Parameters
message
String

The error message that explains the reason for the exception.

paramName
String

The name of the parameter that caused the current exception.

innerException
Exception

The exception that is the cause of the current exception. If the innerException parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.

See Also

Properties

Message

Gets the error message and the parameter name, or only the error message if no parameter name is set.

public override string Message { get; }
Value
String

A text string describing the details of the exception. The value of this property takes one of two forms:

Condition

Value

The paramName is a null reference (Nothing in Visual Basic) or of zero length.

The message string passed to the constructor.

The paramName is not null reference (Nothing in Visual Basic) and it has a length greater than zero.

The message string appended with the name of the invalid parameter.

Overrides

ParamName

Gets the name of the parameter that causes this exception.

public virtual string ParamName { get; }
Value
String

The parameter name.

See Also