ArgumentNullException 建構函式

定義

初始化 ArgumentNullException 類別的新執行個體。Initializes a new instance of the ArgumentNullException class.

多載

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 ()

備註

這個函 Message 式會將新實例的屬性初始化為系統提供的訊息,該訊息會描述錯誤,例如「值不能為 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 null 參考 (在 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);
public ArgumentNullException (string? paramName);
new ArgumentNullException : string -> ArgumentNullException
Public Sub New (paramName As String)

參數

paramName
String

造成例外狀況的參數名稱。The name of the parameter that caused the exception.

備註

這個函 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 null 參考 (在 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
[<System.Security.SecurityCritical>]
new ArgumentNullException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentNullException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

參數

info
SerializationInfo

存放序列物件資料的物件。The object that holds the serialized object data.

context
StreamingContext

物件,描述序列化資料的來源或目的地。An object that describes the source or destination of the serialized data.

屬性

備註

這個建構函式是在還原序列化期間呼叫,以便重新組成透過資料流傳輸的例外狀況物件。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.

適用於

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);
public ArgumentNullException (string? message, Exception? innerException);
new ArgumentNullException : string * Exception -> ArgumentNullException
Public Sub New (message As String, innerException As Exception)

參數

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);
public ArgumentNullException (string? paramName, string? message);
new ArgumentNullException : string * string -> ArgumentNullException
Public Sub New (paramName As String, message As String)

參數

paramName
String

造成例外狀況的參數名稱。The name of the parameter that caused the exception.

message
String

描述錯誤的訊息。A message that describes the error.

備註

這個函式會 Message 使用參數的值,初始化新實例的屬性 messageThis 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 null 參考 (在 Visual Basic 中為 Nothing)。A null reference (Nothing in Visual Basic).
Message 錯誤訊息字串。The error message string.
ParamName 參數名稱字串。The parameter name string.

適用於