Dictionary<TKey,TValue>.Enumerator.Current 属性


获取枚举数当前位置的元素。Gets the element at the current position of the enumerator.

 property System::Collections::Generic::KeyValuePair<TKey, TValue> Current { System::Collections::Generic::KeyValuePair<TKey, TValue> get(); };
public System.Collections.Generic.KeyValuePair<TKey,TValue> Current { get; }
member this.Current : System.Collections.Generic.KeyValuePair<'Key, 'Value>
Public ReadOnly Property Current As KeyValuePair(Of TKey, TValue)



Dictionary<TKey,TValue> 中位于该枚举数当前位置的元素。The element in the Dictionary<TKey,TValue> at the current position of the enumerator.



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

  • 枚举器位于集合的第一个元素之前。The enumerator is positioned before the first element of the collection. 在创建枚举器之后或在 IEnumerator.Reset 调用方法之后发生。That happens after an enumerator is created or after the IEnumerator.Reset method is called. MoveNext 读取属性的值之前,必须调用方法以将枚举数前移到集合的第一个元素 CurrentThe MoveNext method must be called to advance the enumerator to the first element of the collection before reading the value of the Current property.

  • 对返回的的最后一个调用 MoveNext false ,它指示集合的末尾,枚举数置于集合的最后一个元素之后。The last call to MoveNext returned false, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection.

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

Current 不移动枚举器的位置,并且连续调用将 Current 返回相同的对象,直到 MoveNext IEnumerator.Reset 调用或。Current does not move the position of the enumerator, and consecutive calls to Current return the same object until either MoveNext or IEnumerator.Reset is called.