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
[C#]
object Key {get;}
[C++]
__property Object* get_Key();
[JScript]
function get Key() : Object;

Property Value

The key of the current element of the enumeration.

Exceptions

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

-or-

The dictionary is modified after the IDictionaryEnumerator was created.

Remarks

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.

Requirements

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

Show: