ArgumentOutOfRangeException ArgumentOutOfRangeException ArgumentOutOfRangeException ArgumentOutOfRangeException Constructors

定義

多載

ArgumentOutOfRangeException() ArgumentOutOfRangeException() ArgumentOutOfRangeException()

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

ArgumentOutOfRangeException(String) ArgumentOutOfRangeException(String) ArgumentOutOfRangeException(String) 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(SerializationInfo, StreamingContext) ArgumentOutOfRangeException(SerializationInfo, StreamingContext) ArgumentOutOfRangeException(SerializationInfo, StreamingContext)

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

ArgumentOutOfRangeException(String, Exception) ArgumentOutOfRangeException(String, Exception) ArgumentOutOfRangeException(String, Exception) 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(String, String) ArgumentOutOfRangeException(String, String) 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(String, Object, String) ArgumentOutOfRangeException(String, Object, 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.

ArgumentOutOfRangeException() ArgumentOutOfRangeException() 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(String) ArgumentOutOfRangeException(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 String String 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(SerializationInfo, StreamingContext) ArgumentOutOfRangeException(SerializationInfo, StreamingContext) 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 SerializationInfo SerializationInfo SerializationInfo

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

context
StreamingContext StreamingContext StreamingContext 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.

另請參閱

ArgumentOutOfRangeException(String, Exception) ArgumentOutOfRangeException(String, Exception) ArgumentOutOfRangeException(String, Exception) 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 String String String

解釋這個例外狀況原因的錯誤訊息。The error message that explains the reason for this exception.

innerException
Exception Exception Exception 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(String, String) ArgumentOutOfRangeException(String, String) 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 String String String

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

message
String String String String

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

下表顯示 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(String, Object, String) ArgumentOutOfRangeException(String, Object, 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 String String String

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

actualValue
Object Object Object Object

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

message
String String String String

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

備註

這個建構函式初始化ParamName的新執行個體使用的屬性paramName參數ActualValue屬性使用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. 內容paramNamemessage參數要讓人了解。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 Framework 類別庫中。The actualValue parameter is not used within the .NET Framework class library. 不過,ActualValue屬性提供,讓應用程式可以使用提供的引數的值。However, the ActualValue property is provided so that applications can use the available argument value.

actualValue參數包含無效的值傳遞給方法,就會擲回此例外狀況。The actualValue parameter contains an invalid value that is passed to the method and causes this exception to be thrown. 這個值會儲存在ActualValue屬性和它的字串表示附加至保留在訊息字串Message屬性。This 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 Null 參考 (Nothing Visual Basic 中)。The null reference (Nothing in Visual Basic).
Message 錯誤訊息字串。The error message string.
ParamName 參數名稱的字串。The parameter name string.

適用於