SortedDictionary<TKey,TValue>.Enumerator.IDictionaryEnumerator.Key 属性

定义

获取位于枚举数当前位置的元素的键。

property System::Object ^ System::Collections::IDictionaryEnumerator::Key { System::Object ^ get(); };
object System.Collections.IDictionaryEnumerator.Key { get; }
member this.System.Collections.IDictionaryEnumerator.Key : obj
 ReadOnly Property Key As Object Implements IDictionaryEnumerator.Key

属性值

集合中位于该枚举数当前位置的元素的键。

实现

Key

例外

枚举器位于集合中第一个元素之前或最后一个元素之后。

注解

IDictionaryEnumerator.Key 在以下任一条件下未定义:

  • 枚举器位于集合的第一个元素之前。 在创建枚举器或调用 方法之后, IEnumerator.Reset 就会发生这种情况。 MoveNext在读取 属性的值IDictionaryEnumerator.Key之前,必须调用 方法以将枚举器推进到集合的第一个元素。

  • 对返回false的最后一MoveNext次调用,它指示集合的末尾,并且枚举器位于集合的最后一个元素之后。

  • 枚举器由于集合中的更改(例如添加、修改或删除元素)而失效。

IDictionaryEnumerator.Key 不会移动枚举器的位置,并且连续调用 以 IDictionaryEnumerator.Key 返回同一对象,直到 MoveNext 调用 或 IEnumerator.Reset

适用于

另请参阅