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);
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);
[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)

參數

info
SerializationInfo

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

context
StreamingContext

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

屬性

備註

進行還原序列化 (Deserialization) 期間會呼叫這個建構函式,以便重新構成經由資料流傳送的例外狀況物件。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.

安全性

SecurityPermission
提供序列化服務。for providing serialization services. 相關聯的列舉: SerializationFormatter安全性動作:LinkDemandAssociated enumeration: SerializationFormatter Security action: LinkDemand

SecurityCriticalAttribute
需要完全信任立即呼叫者。requires full trust for the immediate caller. 部分信任或透明的程式碼無法使用這個成員。This member cannot be used by partially trusted or transparent code.

另請參閱

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)

參數

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)

參數

paramName
String

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

message
String

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

備註

這個函式會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 null 參考 (在 Visual Basic 中為 Nothing)。A null reference (Nothing in Visual Basic).
Message 錯誤訊息字串。The error message string.
ParamName 參數名稱字串。The parameter name string.

適用於