Class ArgumentException
The exception that is thrown when one of the arguments provided to a method is not valid.
Inheritance
Inherited Members
Namespace: System
Assembly: mscorlib.dll
Syntax
public class ArgumentException : SystemException
Constructors
ArgumentException()
Initializes a new instance of the ArgumentException class.
Declaration
public ArgumentException()
ArgumentException(string)
Initializes a new instance of the ArgumentException class with a specified error message.
Declaration
public ArgumentException(string message)
Parameters
Type | Name | Description |
---|---|---|
string | message | 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.
Declaration
public ArgumentException(string message, Exception innerException)
Parameters
Type | Name | Description |
---|---|---|
string | message | The error message that explains the reason for the exception. |
Exception | innerException | 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. |
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.
Declaration
public ArgumentException(string message, string paramName)
Parameters
Type | Name | Description |
---|---|---|
string | message | The error message that explains the reason for the exception. |
string | paramName | 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.
Declaration
public ArgumentException(string message, string paramName, Exception innerException)
Parameters
Type | Name | Description |
---|---|---|
string | message | The error message that explains the reason for the exception. |
string | paramName | The name of the parameter that caused the current exception. |
Exception | innerException | 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. |
Properties
Message
Gets the error message and the parameter name, or only the error message if no parameter name is set.
Declaration
public override string Message { get; }
Property Value
Type | Description |
---|---|
string | A text string describing the details of the exception. |
Overrides
ParamName
Gets the name of the parameter that causes this exception.
Declaration
public virtual string ParamName { get; }
Property Value
Type | Description |
---|---|
string | The parameter name. |