IDictionaryEnumerator.Key 属性


获取当前字典项的键。Gets the key of the current dictionary entry.

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


当前枚举元素的键。The key of the current element of the enumeration.


IDictionaryEnumerator 定位于字典的第一项之前或最后一项之后。The IDictionaryEnumerator is positioned before the first entry of the dictionary or after the last entry.


Key在以下任何条件下均未定义:Key is undefined under any of the following conditions:

  • 枚举器位于集合中第一个元素之前, 紧跟在创建枚举器之后。The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. MoveNext在读取的值Key之前, 必须调用以将枚举数前移到集合的第一个元素。MoveNext must be called to advance the enumerator to the first element of the collection before reading the value of Key.

  • MoveNext 返回false的最后一个调用, 指示集合的末尾。The last call to MoveNext returned false, which indicates the end of the collection.

  • 由于对集合所做的更改 (如添加、修改或删除元素), 枚举器无效。The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements.

在调用 Key 之前,MoveNext 返回相同的对象。Key returns the same object until MoveNext is called. MoveNext设置Key为枚举中的下一个元素的键。MoveNext sets Key to the key of the next element in enumeration.