This documentation is archived and is not being maintained.

IDictionaryEnumerator.Key Property

When implemented by a class, gets the key of the current dictionary entry.

[Visual Basic]
ReadOnly Property Key As Object
object Key {get;}
__property Object* get_Key();
function get Key() : Object;

Property Value

The key of the current element of the enumeration.


Exception Type Condition
InvalidOperationException The IDictionaryEnumerator is positioned before the first entry of the dictionary or after the last entry.


The dictionary is modified after the IDictionaryEnumerator was created.


After an enumerator is created or after a Reset, MoveNext must be called to advance the enumerator to the first element of the collection before reading the value of Key; otherwise, Key is undefined.

Key also throws an exception if the last call to MoveNext returned false, which indicates the end of the collection.

Key does not move the position of the enumerator and consecutive calls to Key return the same object until either MoveNext or Reset is called.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

IDictionaryEnumerator Interface | IDictionaryEnumerator Members | System.Collections Namespace | Reset | MoveNext | Value | Entry