Queue<T>.Enumerator.IEnumerator.Current 屬性

定義

取得位於目前列舉值位置的項目。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; }
member this.System.Collections.IEnumerator.Current : obj
 ReadOnly Property Current As Object Implements IEnumerator.Current

屬性值

Object

位於列舉值中目前位置的集合中的元素。The element in the collection at the current position of the enumerator.

實作

例外狀況

列舉值是放在集合的第一個項目之前,或最後一個項目之後。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.

適用於

另請參閱