System.Collections.Generic.KeyNotFoundException Class

The exception that is thrown when the key specified for accessing an element in a collection does not match any key in the collection.

See Also: KeyNotFoundException Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public class KeyNotFoundException : SystemException

Remarks

A KeyNotFoundException is thrown when an operation attempts to retrieve an element from a collection using a key that does not exist in that collection.

KeyNotFoundException uses the HRESULT COR_E_KEYNOTFOUND, which has the value 0x80131577.

For a list of initial property values for an instance of the KeyNotFoundException class, see the erload:System.Collections.Generic.KeyNotFoundException.#ctor constructors.

Requirements

Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0