Export (0) Print
Expand All
Expand Minimize

Troubleshooting Exceptions: System.Collections.Generic.KeyNotFoundException

A KeyNotFoundException is thrown when an attempt is made to retrieve a key or key value pair from a collection using a nonexistent key.

Check that the key you are using exists in the collection you are attempting to access.

This exception occurs when an operation attempts to retrieve an element in a collection using a key that does not exist in that collection.

Remarks

The ContainsKey method can be used to determine whether a key exists.

Community Additions

ADD
Show:
© 2015 Microsoft