KeyNotFoundException 构造函数

定义

初始化 KeyNotFoundException 类的新实例。

重载

名称 说明
KeyNotFoundException()

使用默认属性值初始化类的新实例 KeyNotFoundException

KeyNotFoundException(String)

使用指定的错误消息初始化类的新实例 KeyNotFoundException

KeyNotFoundException(SerializationInfo, StreamingContext)
已过时.

使用序列化的数据初始化 KeyNotFoundException 类的新实例。

KeyNotFoundException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用初始化 KeyNotFoundException 类的新实例。

KeyNotFoundException()

Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs

使用默认属性值初始化类的新实例 KeyNotFoundException

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

注解

此构造函数将 Message 新实例的属性初始化为系统提供的消息,该消息描述错误,例如“给定键不存在于字典中”。此消息将考虑当前系统区域性。

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

财产 价值
InnerException null
Message 本地化的错误消息字符串。

适用于

KeyNotFoundException(String)

Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs

使用指定的错误消息初始化类的新实例 KeyNotFoundException

public:
 KeyNotFoundException(System::String ^ message);
public KeyNotFoundException(string message);
public KeyNotFoundException(string? message);
new System.Collections.Generic.KeyNotFoundException : string -> System.Collections.Generic.KeyNotFoundException
Public Sub New (message As String)

参数

message
String

描述错误的消息。

注解

参数的内容 message 旨在由人类理解。 此构造函数的调用方必须确保此字符串已本地化为当前系统区域性。

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

财产 价值
InnerException null
Message 本地化的错误消息字符串。

适用于

KeyNotFoundException(SerializationInfo, StreamingContext)

Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs

注意

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

使用序列化的数据初始化 KeyNotFoundException 类的新实例。

protected:
 KeyNotFoundException(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 KeyNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected KeyNotFoundException(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 System.Collections.Generic.KeyNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Generic.KeyNotFoundException
new System.Collections.Generic.KeyNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Generic.KeyNotFoundException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo

保存所引发异常的序列化对象数据的 SerializationInfo

context
StreamingContext

包含有关源或目标的上下文信息的 StreamingContext

属性

注解

在反序列化期间调用此构造函数以重新构造通过流传输的异常对象。 有关详细信息,请参阅 XML 和 SOAP 序列化

适用于

KeyNotFoundException(String, Exception)

Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs
Source:
KeyNotFoundException.cs

使用指定的错误消息和对作为此异常原因的内部异常的引用初始化 KeyNotFoundException 类的新实例。

public:
 KeyNotFoundException(System::String ^ message, Exception ^ innerException);
public KeyNotFoundException(string message, Exception innerException);
public KeyNotFoundException(string? message, Exception? innerException);
new System.Collections.Generic.KeyNotFoundException : string * Exception -> System.Collections.Generic.KeyNotFoundException
Public Sub New (message As String, innerException As Exception)

参数

message
String

解释异常原因的错误消息。

innerException
Exception

是当前异常原因的异常。 如果未 innerExceptionnull 参数,则会在处理内部异常的 catch 块中引发当前异常。

注解

作为上一个异常的直接结果引发的异常应包括对 InnerException 属性中上一个异常的引用。 InnerException 属性返回传入构造函数的相同值,或者如果 null 属性未向构造函数提供内部异常值,则返回 InnerException

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

财产 价值
InnerException 内部异常引用。
Message 本地化的错误消息字符串。

适用于