public:
ArgumentException();
public ArgumentException();
Public Sub New ()
Remarks
This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "An invalid argument was specified." This message takes into account the current system culture.
The following table shows the initial property values for an instance of ArgumentException.
Property Value InnerException A null reference (Nothing
in Visual Basic). Message The localized error message string. ArgumentException(String)
Initializes a new instance of the ArgumentException class with a specified error message.
public:
ArgumentException(System::String ^ message);
public ArgumentException(string message);
public ArgumentException(string? message);
new ArgumentException : string -> ArgumentException
Public Sub New (message As String)
Parameters
The error message that explains the reason for the exception.
RemarksThis constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "An invalid argument was specified." This message takes into account the current system culture.
The following table shows the initial property values for an instance of ArgumentException.
Property Value InnerException A null reference (Nothing
in Visual Basic). Message The error message string. ArgumentException(SerializationInfo, StreamingContext)
Caution
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
protected:
ArgumentException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected ArgumentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected ArgumentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new ArgumentException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentException
new ArgumentException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentException
Protected Sub New (info As SerializationInfo, context As StreamingContext)
Parameters
The contextual information about the source or destination.
This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. For more information, see XML and SOAP Serialization.
See also 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(System::String ^ message, Exception ^ innerException);
public ArgumentException(string message, Exception innerException);
public ArgumentException(string? message, Exception? innerException);
new ArgumentException : string * Exception -> ArgumentException
Public Sub New (message As String, innerException As Exception)
Parameters
The error message that explains the reason for the 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.
This constructor initializes the Message property of the new instance using the value of the message
parameter. The content of the message
parameter is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. The InnerException property returns the same value that is passed into the constructor, or null
if the InnerException property does not supply the inner exception value to the constructor.
The following table shows the initial property values for an instance of ArgumentException.
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(System::String ^ message, System::String ^ paramName);
public ArgumentException(string message, string paramName);
public ArgumentException(string? message, string? paramName);
new ArgumentException : string * string -> ArgumentException
Public Sub New (message As String, paramName As String)
Parameters
The error message that explains the reason for the exception.
The name of the parameter that caused the current exception.
ExamplesThe following code example demonstrates how to call the ArgumentException constructor. This code example is part of a larger example provided for the ArgumentException class.
static int DivideByTwo(int num)
{
// If num is an odd number, throw an ArgumentException.
if ((num & 1) == 1)
throw new ArgumentException("Number must be even", "num");
// num is even, return half of its value.
return num / 2;
}
let divideByTwo num =
// If num is an odd number, raise an ArgumentException.
if num % 2 = 1 then
raise (ArgumentException("num", "Number must be even"))
// num is even, return half of its value.
num / 2;
Remarks
This constructor initializes the Message property of the new instance using the value of the message
parameter. The content of the message
parameter is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
This constructor initializes the ParamName property of the new instance using paramName
. The content of paramName
is intended to be understood by humans.
The following table shows the initial property values for an instance of ArgumentException.
Property Value Message The error message string. ParamName The parameter name string. 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(System::String ^ message, System::String ^ paramName, Exception ^ innerException);
public ArgumentException(string message, string paramName, Exception innerException);
public ArgumentException(string? message, string? paramName, Exception? innerException);
new ArgumentException : string * string * Exception -> ArgumentException
Public Sub New (message As String, paramName As String, innerException As Exception)
Parameters
The error message that explains the reason for the exception.
The name of the parameter that caused the current 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.
This constructor initializes the Message property of the new instance using the value of the message
parameter. The content of the message
parameter is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
This constructor initializes the ParamName property of the new instance using paramName
. The content of paramName
is intended to be understood by humans.
An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. The InnerException property returns the same value that is passed into the constructor, or null
if the InnerException property does not supply the inner exception value to the constructor.
The following table shows the initial property values for an instance of ArgumentException.
See alsoCollaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4