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 空引用(在 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 空引用(在 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 参数的值初始化新实例的 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 nullnull.
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 参数、使用 actualValue 参数的 ActualValue 属性和使用 Message 参数的 message 属性初始化新实例的 ParamName 属性。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 空引用(Nothing Visual Basic)。The null reference (Nothing in Visual Basic).
Message 错误消息字符串。The error message string.
ParamName 参数名称字符串。The parameter name string.

适用于