ArgumentNullException Constructors

Definition

初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class.

Overloads

ArgumentNullException()

初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class.

ArgumentNullException(String)

使用导致此异常的参数的名称初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class with the name of the parameter that causes this exception.

ArgumentNullException(SerializationInfo, StreamingContext)

使用序列化数据初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class with serialized data.

ArgumentNullException(String, Exception)

使用指定的错误消息和引发此异常的异常初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class with a specified error message and the exception that is the cause of this exception.

ArgumentNullException(String, String)

使用指定的错误消息和导致此异常的参数的名称来初始化 ArgumentNullException 类的实例。Initializes an instance of the ArgumentNullException class with a specified error message and the name of the parameter that causes this exception.

ArgumentNullException()

初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class.

public:
 ArgumentNullException();
public ArgumentNullException ();
Public Sub New ()

Remarks

此构造函数将新实例的 Message 属性初始化为系统提供的描述错误的消息,如 "Value 不能为 null。"This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "Value cannot be null." 此消息会考虑当前系统区域性。This message takes into account the current system culture.

下表显示了 ArgumentNullException 实例的初始属性值。The following table shows the initial property values for an instance of ArgumentNullException.

属性Property Value
InnerException 空引用(在 Visual Basic 中为 Nothing)。A null reference (Nothing in Visual Basic).
Message 本地化的错误消息字符串,如 "值不能为 null。"A localized error message string, such as "Value cannot be null." 适用于英语。for the English language.

ArgumentNullException(String)

使用导致此异常的参数的名称初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class with the name of the parameter that causes this exception.

public:
 ArgumentNullException(System::String ^ paramName);
public ArgumentNullException (string paramName);
new ArgumentNullException : string -> ArgumentNullException
Public Sub New (paramName As String)

Parameters

paramName
String

导致异常的参数的名称。The name of the parameter that caused the exception.

Remarks

此构造函数将新实例的 Message 属性初始化为系统提供的消息,该消息描述错误并包含参数名称。This constructor initializes the Message property of the new instance to a system-supplied message that describes the error and includes the parameter name. 此消息会考虑当前系统区域性。This message takes into account the current system culture.

此构造函数用 ParamName 参数初始化新实例的 paramName 属性。This constructor initializes the ParamName property of the new instance using the paramName parameter. paramName 的内容设计为易于理解。The content of paramName is intended to be understood by humans.

下表显示了 ArgumentNullException 实例的初始属性值。The following table shows the initial property values for an instance of ArgumentNullException.

属性Property Value
InnerException 空引用(在 Visual Basic 中为 Nothing)。A null reference (Nothing in Visual Basic).
Message 标识 null 参数的本地化错误消息字符串。A localized error message string that identifies the null argument. 例如,如果 paramName 参数为 "arg1",则英语消息字符串为:For example, if the paramName argument is "arg1", the English language message string is:

Value cannot be null.Parameter name: arg01
ParamName 参数名称字符串。The parameter name string.

ArgumentNullException(SerializationInfo, StreamingContext)

使用序列化数据初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class with serialized data.

protected:
 ArgumentNullException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ArgumentNullException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Security.SecurityCritical]
protected ArgumentNullException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new ArgumentNullException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentNullException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameters

info
SerializationInfo

包含序列化对象数据的对象。The object that holds the serialized object data.

context
StreamingContext

用于描述序列化数据的源或目标的对象。An object that describes the source or destination of the serialized data.

Attributes

Remarks

在反序列化期间调用此构造函数以重新构造在流上传输的异常对象。This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. 有关详细信息,请参阅XML 和 SOAP 序列化For more information, see XML and SOAP Serialization.

See also

ArgumentNullException(String, Exception)

使用指定的错误消息和引发此异常的异常初始化 ArgumentNullException 类的新实例。Initializes a new instance of the ArgumentNullException class with a specified error message and the exception that is the cause of this exception.

public:
 ArgumentNullException(System::String ^ message, Exception ^ innerException);
public ArgumentNullException (string message, Exception innerException);
new ArgumentNullException : string * Exception -> ArgumentNullException
Public Sub New (message As String, innerException As Exception)

Parameters

message
String

说明发生此异常的原因的错误消息。The error message that explains the reason for this exception.

innerException
Exception

导致当前异常的异常;如果未指定内部异常,则是一个 null 引用(在 Visual Basic 中为 Nothing)。The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.

ArgumentNullException(String, String)

使用指定的错误消息和导致此异常的参数的名称来初始化 ArgumentNullException 类的实例。Initializes an instance of the ArgumentNullException class with a specified error message and the name of the parameter that causes this exception.

public:
 ArgumentNullException(System::String ^ paramName, System::String ^ message);
public ArgumentNullException (string paramName, string message);
new ArgumentNullException : string * string -> ArgumentNullException
Public Sub New (paramName As String, message As String)

Parameters

paramName
String

导致异常的参数的名称。The name of the parameter that caused the exception.

message
String

描述错误的消息。A message that describes the error.

Remarks

此构造函数使用 message 参数的值初始化新实例的 Message 属性。This constructor initializes the Message property of the new instance using the value of the message parameter. message 参数的内容应为人所理解。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.

此构造函数用 ParamName 参数初始化新实例的 paramName 属性。This constructor initializes the ParamName property of the new instance using the paramName parameter. paramName 的内容设计为易于理解。The content of paramName is intended to be understood by humans.

下表显示了 ArgumentNullException 实例的初始属性值。The following table shows the initial property values for an instance of ArgumentNullException.

属性Property Value
InnerException 空引用(在 Visual Basic 中为 Nothing)。A null reference (Nothing in Visual Basic).
Message 错误消息字符串。The error message string.
ParamName 参数名称字符串。The parameter name string.

Applies to