public class KeyNotFoundException: SystemException
Object
Exception
SystemException
KeyNotFoundException
mscorlib
BCL
The exception that is thrown when the key specified for accessing an element in a collection does not match any key in the collection.
System.Collections.Generic Namespace
KeyNotFoundException Constructors
KeyNotFoundException() Constructor
KeyNotFoundException(System.String) Constructor
KeyNotFoundException(System.String, System.Exception) Constructor
public KeyNotFoundException()
Constructs and initializes a new instance of the System.KeyNotFoundException class.
This constructor initializes the System.KeyNotFoundException.Message property of the new instance to a system-supplied message that describes the error, such as "An application error has occurred." This message takes into account the current system culture.The System.KeyNotFoundException.InnerException property is initialized to
null
.
System.Collections.Generic.KeyNotFoundException Class, System.Collections.Generic Namespace
public KeyNotFoundException(string message)
Constructs and initializes a new instance of the System.KeyNotFoundException class.
- message
- The message that describes the error. The content of message is intended to be understandable to the user. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
This constructor initializes the System.KeyNotFoundException.Message property of the new instance using message. If message isnull
, the System.KeyNotFoundException.Message property is initialized to an implementation-specific message. The System.KeyNotFoundException.InnerException property is initialized tonull
.
System.Collections.Generic.KeyNotFoundException Class, System.Collections.Generic Namespace
public KeyNotFoundException(string message, Exception innerException)
Constructs and initializes a new instance of the System.KeyNotFoundException class.
- message
- The message that describes the error. The content of message is intended to be understandable to the user. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
- innerException
- An instance of Exception that is the cause of the current Exception. If innerException is non-
null
, then the current exception was raised in a catch block handling innerException.
This constructor initializes the System.KeyNotFoundException.Message property of the new instance using message, and the System.KeyNotFoundException.InnerException property using innerException. If message isnull
, the System.KeyNotFoundException.Message property is initialized to an implementation-specific message.[Note: For information on inner exceptions, see System.Exception.InnerException.]
System.Collections.Generic.KeyNotFoundException Class, System.Collections.Generic Namespace