ArgumentOutOfRangeException 建構函式

定義

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

多載

ArgumentOutOfRangeException()

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

ArgumentOutOfRangeException(String)

使用造成這個例外狀況的參數名稱來初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with the name of the parameter that causes this exception.

ArgumentOutOfRangeException(SerializationInfo, StreamingContext)

使用序列化資料,初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with serialized data.

ArgumentOutOfRangeException(String, Exception)

使用指定的錯誤訊息和造成這個例外狀況的例外狀況,初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with a specified error message and the exception that is the cause of this exception.

ArgumentOutOfRangeException(String, String)

使用造成這個例外狀況的參數名稱和指定的錯誤訊息,初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with the name of the parameter that causes this exception and a specified error message.

ArgumentOutOfRangeException(String, Object, String)

使用參數名稱引數值和指定的錯誤訊息,初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with the parameter name, the value of the argument, and a specified error message.

ArgumentOutOfRangeException()

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

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

備註

這個函 Message 式會將新實例的屬性初始化為系統提供的訊息,該訊息會描述錯誤,例如「需要非負數位」。This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "Nonnegative number required." 此訊息會考慮到目前系統的文化特性。This message takes into account the current system culture.

下表顯示 ArgumentOutOfRangeException 執行個體的初始屬性值。The following table shows the initial property values for an instance of ArgumentOutOfRangeException.

屬性Property Value
InnerException null 參考 (在 Visual Basic 中為 Nothing)。A null reference (Nothing in Visual Basic).
Message 當地語系化的錯誤訊息字串。The localized error message string.

適用於

ArgumentOutOfRangeException(String)

使用造成這個例外狀況的參數名稱來初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with the name of the parameter that causes this exception.

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

參數

paramName
String

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

備註

這個函 Message 式會將新實例的屬性初始化為系統提供的訊息,該訊息會描述錯誤,例如「需要非負數位」。This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "Nonnegative number required." 此訊息會考慮到目前系統的文化特性。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.

下表顯示 ArgumentOutOfRangeException 執行個體的初始屬性值。The following table shows the initial property values for an instance of ArgumentOutOfRangeException.

屬性Property Value
InnerException null 參考 (在 Visual Basic 中為 Nothing)。A null reference (Nothing in Visual Basic).
Message ( "" ) 的空字串。The empty string ("").
ParamName 參數名稱字串。The parameter name string.

適用於

ArgumentOutOfRangeException(SerializationInfo, StreamingContext)

使用序列化資料,初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with serialized data.

protected:
 ArgumentOutOfRangeException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ArgumentOutOfRangeException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new ArgumentOutOfRangeException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentOutOfRangeException
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.

另請參閱

適用於

ArgumentOutOfRangeException(String, Exception)

使用指定的錯誤訊息和造成這個例外狀況的例外狀況,初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with a specified error message and the exception that is the cause of this exception.

public:
 ArgumentOutOfRangeException(System::String ^ message, Exception ^ innerException);
public ArgumentOutOfRangeException (string message, Exception innerException);
new ArgumentOutOfRangeException : string * Exception -> ArgumentOutOfRangeException
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.

適用於

ArgumentOutOfRangeException(String, String)

使用造成這個例外狀況的參數名稱和指定的錯誤訊息,初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with the name of the parameter that causes this exception and a specified error message.

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

參數

paramName
String

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

message
String

描述錯誤的訊息。The 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.

下表顯示 ArgumentOutOfRangeException 執行個體的初始屬性值。The following table shows the initial property values for an instance of ArgumentOutOfRangeException.

屬性Property Value
InnerException null.null.
Message 錯誤訊息字串。The error message string.
ParamName 參數名稱字串。The parameter name string.

適用於

ArgumentOutOfRangeException(String, Object, String)

使用參數名稱引數值和指定的錯誤訊息,初始化 ArgumentOutOfRangeException 類別的新執行個體。Initializes a new instance of the ArgumentOutOfRangeException class with the parameter name, the value of the argument, and a specified error message.

public:
 ArgumentOutOfRangeException(System::String ^ paramName, System::Object ^ actualValue, System::String ^ message);
public ArgumentOutOfRangeException (string paramName, object actualValue, string message);
new ArgumentOutOfRangeException : string * obj * string -> ArgumentOutOfRangeException
Public Sub New (paramName As String, actualValue As Object, message As String)

參數

paramName
String

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

actualValue
Object

造成例外狀況的引數名稱。The value of the argument that causes this exception.

message
String

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

備註

這個函式會 ParamName 使用參數 paramNameActualValue 使用參數的屬性 actualValue ,以及 Message 使用參數的屬性 message ,初始化新實例的屬性。This constructor initializes the ParamName property of the new instance using the paramName parameter, the ActualValue property using the actualValue parameter, and the Message property using the message parameter. 和參數的內容 paramName message 是要供人類理解。The content of the paramName and message parameters is intended to be understood by humans. 需要此函式的呼叫者,才能確保這些字串已針對目前的系統文化特性當地語系化。The caller of this constructor is required to ensure that these strings have been localized for the current system culture.

actualValue 參數不是在 .net 類別庫中使用。The actualValue parameter is not used within the .NET class library. 不過,應用程式可以使用 ActualValue 屬性來取得可用的引數值。However, apps can use the ActualValue property to obtain the available argument value.

actualValue參數包含傳遞給方法的無效值,並導致擲回此例外狀況。The actualValue parameter contains the invalid value that was passed to the method and caused this exception to be thrown. 這個值會儲存在 ActualValue 屬性中,而其字串表示會附加至保存在屬性中的訊息字串 MessageThis value is stored in the ActualValue property and its string representation is appended to the message string held in the Message property.

下表顯示 ArgumentOutOfRangeException 執行個體的初始屬性值。The following table shows the initial property values for an instance of ArgumentOutOfRangeException.

屬性Property Value
ActualValue 引數值。The argument value.
InnerException (Nothing Visual Basic) 中的 null 參考。The null reference (Nothing in Visual Basic).
Message 錯誤訊息字串。The error message string.
ParamName 參數名稱字串。The parameter name string.

適用於