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.

PropertyProperty “值”Value
InnerException 空引用(在 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.

PropertyProperty “值”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(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.

注解

此构造函数在反序列化过程中调用,以便重建通过流传输的异常对象。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.

PropertyProperty Value
InnerException nullnull.
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.

PropertyProperty 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.

适用于