ArgumentOutOfRangeException 建構函式

定義

初始化 ArgumentOutOfRangeException 類別的新執行個體。

多載

ArgumentOutOfRangeException()

初始化 ArgumentOutOfRangeException 類別的新執行個體。

ArgumentOutOfRangeException(String)

使用造成這個例外狀況的參數名稱來初始化 ArgumentOutOfRangeException 類別的新執行個體。

ArgumentOutOfRangeException(SerializationInfo, StreamingContext)
已淘汰.

使用序列化資料,初始化 ArgumentOutOfRangeException 類別的新執行個體。

ArgumentOutOfRangeException(String, Exception)

使用指定的錯誤訊息和造成這個例外狀況的例外狀況,初始化 ArgumentOutOfRangeException 類別的新執行個體。

ArgumentOutOfRangeException(String, String)

使用造成這個例外狀況的參數名稱和指定的錯誤訊息,初始化 ArgumentOutOfRangeException 類別的新執行個體。

ArgumentOutOfRangeException(String, Object, String)

使用參數名稱引數值和指定的錯誤訊息,初始化 ArgumentOutOfRangeException 類別的新執行個體。

ArgumentOutOfRangeException()

初始化 ArgumentOutOfRangeException 類別的新執行個體。

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

備註

這個建構函式會將 Message 新實例的 屬性初始化為系統提供的訊息,描述錯誤,例如「需要非負數」。此訊息會將目前的系統文化特性納入考慮。

下表顯示 ArgumentOutOfRangeException 執行個體的初始屬性值。

屬性
InnerException null 參考 (在 Visual Basic 中為 Nothing)。
Message 當地語系化的錯誤訊息字串。

適用於

ArgumentOutOfRangeException(String)

使用造成這個例外狀況的參數名稱來初始化 ArgumentOutOfRangeException 類別的新執行個體。

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

參數

paramName
String

造成這個例外狀況的參數名稱。

備註

這個建構函式會將 Message 新實例的 屬性初始化為系統提供的訊息,描述錯誤,例如「需要非負數」。此訊息會將目前的系統文化特性納入考慮。

這個建構函式使用 ParamName 參數來初始化新執行個體的 paramName 屬性。 paramName 的內容必須能讓人了解。

下表顯示 ArgumentOutOfRangeException 執行個體的初始屬性值。

屬性
InnerException null 參考 (在 Visual Basic 中為 Nothing)。
Message 空字串 (「」) 。
ParamName 參數名稱字串。

適用於

ArgumentOutOfRangeException(SerializationInfo, StreamingContext)

警告

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

使用序列化資料,初始化 ArgumentOutOfRangeException 類別的新執行個體。

protected:
 ArgumentOutOfRangeException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ArgumentOutOfRangeException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected ArgumentOutOfRangeException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new ArgumentOutOfRangeException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentOutOfRangeException
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new ArgumentOutOfRangeException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentOutOfRangeException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

參數

info
SerializationInfo

存放序列物件資料的物件。

context
StreamingContext

物件,描述序列化資料的來源或目的地。

屬性

備註

這個建構函式是在還原序列化期間呼叫,以便重新組成透過資料流傳輸的例外狀況物件。 如需詳細資訊,請參閱 < XML 和 SOAP 序列化

另請參閱

適用於

ArgumentOutOfRangeException(String, Exception)

使用指定的錯誤訊息和造成這個例外狀況的例外狀況,初始化 ArgumentOutOfRangeException 類別的新執行個體。

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

解釋這個例外狀況原因的錯誤訊息。

innerException
Exception

造成目前例外狀況的例外狀況,若未指定內部例外狀況,則為 null 參考 (Visual Basic 中為 Nothing)。

適用於

ArgumentOutOfRangeException(String, String)

使用造成這個例外狀況的參數名稱和指定的錯誤訊息,初始化 ArgumentOutOfRangeException 類別的新執行個體。

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

參數

paramName
String

造成例外狀況的參數名稱。

message
String

描述錯誤的訊息。

備註

這個建構函式會使用 參數的值,初始化 Message 新實例的 message 屬性。 message 參數的內容必須能讓人了解。 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。

這個建構函式使用 ParamName 參數來初始化新執行個體的 paramName 屬性。 paramName 的內容必須能讓人了解。

下表顯示 ArgumentOutOfRangeException 執行個體的初始屬性值。

屬性
InnerException null.
Message 錯誤訊息字串。
ParamName 參數名稱字串。

適用於

ArgumentOutOfRangeException(String, Object, String)

使用參數名稱引數值和指定的錯誤訊息,初始化 ArgumentOutOfRangeException 類別的新執行個體。

public:
 ArgumentOutOfRangeException(System::String ^ paramName, System::Object ^ actualValue, System::String ^ message);
public ArgumentOutOfRangeException (string paramName, object actualValue, 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

造成例外狀況的參數名稱。

actualValue
Object

造成例外狀況的引數名稱。

message
String

描述錯誤的訊息。

備註

這個建構函式會使用 paramName 參數、 ActualValue 使用 actualValue 參數的屬性,以及 Message 使用 message 參數的屬性,初始化 ParamName 新實例的 屬性。 和 message 參數的內容 paramName 旨在由人類瞭解。 需要此建構函式的呼叫端,以確保這些字串已針對目前的系統文化特性進行當地語系化。

. actualValue NET 類別庫內不會使用 參數。 不過,應用程式可以使用 ActualValue 屬性來取得可用的引數值。

參數 actualValue 包含傳遞至 方法並導致擲回此例外狀況的無效值。 這個值會儲存在 屬性中 ActualValue ,而且其字串表示會附加至屬性中保留的 Message 訊息字串。

下表顯示 ArgumentOutOfRangeException 執行個體的初始屬性值。

屬性
ActualValue 引數值。
InnerException Visual Basic) 中的 null 參考 Nothing (。
Message 錯誤訊息字串。
ParamName 參數名稱字串。

適用於