HashSet<T>.Enumerator.IEnumerator.Current HashSet<T>.Enumerator.IEnumerator.Current HashSet<T>.Enumerator.IEnumerator.Current Property


取得位於目前列舉值位置的項目。Gets the element at the current position of the enumerator.

property System::Object ^ System::Collections::IEnumerator::Current { System::Object ^ get(); };
object System.Collections.IEnumerator.Current { get; }
 ReadOnly Property Current As Object Implements IEnumerator.Current


位於集合中列舉值目前位置的項目,做為 ObjectThe element in the collection at the current position of the enumerator, as an Object.



列舉值是放在集合的第一個項目之前,或最後一個項目之後。The enumerator is positioned before the first element of the collection or after the last element.


IEnumerator.Current 未定義任何下列的情況下:IEnumerator.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列舉值前進到第一個元素的集合,再讀取的值,就必須呼叫方法IEnumerator.Current屬性。The MoveNext method must be called to advance the enumerator to the first element of the collection before reading the value of the IEnumerator.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.

IEnumerator.Current 不會移動的列舉值,以及連續呼叫位置IEnumerator.Current傳回相同的物件,直到MoveNextIEnumerator.Reset呼叫。IEnumerator.Current does not move the position of the enumerator, and consecutive calls to IEnumerator.Current return the same object until either MoveNext or IEnumerator.Reset is called.