通过


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()

Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs

初始化 ArgumentOutOfRangeException 类的新实例。

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

注解

此构造函数将 Message 新实例的属性初始化为系统提供的消息,该消息描述错误,例如“需要非负数”。此消息将考虑当前系统区域性。

下表显示了 ArgumentOutOfRangeException实例的初始属性值。

财产 价值
InnerException Null 引用(Nothing 在 Visual Basic 中)。
Message 本地化的错误消息字符串。

适用于

ArgumentOutOfRangeException(String)

Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs

使用导致此异常的参数名称初始化类的新实例 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 引用(Nothing 在 Visual Basic 中)。
Message 空字符串(“)。
ParamName 参数名称字符串。

适用于

ArgumentOutOfRangeException(SerializationInfo, StreamingContext)

Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs

注意

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);
[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);
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}")>]
new ArgumentOutOfRangeException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentOutOfRangeException
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)

Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs

使用指定的错误消息和导致此异常的异常初始化类的新实例 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 引用(Nothing 在 Visual Basic 中)。

适用于

ArgumentOutOfRangeException(String, String)

Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs

使用导致此异常的参数的名称和指定的错误消息初始化类的新实例 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)

Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs
Source:
ArgumentOutOfRangeException.cs

使用参数名称、参数值和指定的错误消息初始化类的新实例 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 null 引用(Nothing 在 Visual Basic 中)。
Message 错误消息字符串。
ParamName 参数名称字符串。

适用于