When implemented by a class, retrieves the key of the current dictionary entry.
[Visual Basic] ReadOnly Property Key As Object [C#] object Key {get;} [C++] Object* get_Key() = 0; [JScript] abstract function get Key() : Object;
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.
-or- The dictionary is modified after the IDictionaryEnumerator was created. |
After an enumerator is created or after a call to Reset, MoveNext must be called to advance the enumerator to the first entry of the dictionary before calling the Key method.
Key will also throw 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 multiple calls to Key will return the same object until either MoveNext or Reset is called.
IDictionaryEnumerator Interface | IDictionaryEnumerator Members | System.Collections Namespace | Reset | MoveNext | Value