IEnumeratorContract<T> 介面


列舉 IListContract<T> 集合中的項目。Enumerates the elements in an IListContract<T> collection.

generic <typename T>
public interface class IEnumeratorContract : IDisposable
public interface IEnumeratorContract<T> : IDisposable
type IEnumeratorContract<'T> = interface
    interface IDisposable
Public Interface IEnumeratorContract(Of T)
Implements IDisposable



列舉中物件的型別。The type of objects being enumerated.



列舉值可以用來讀取集合中的資料, 但是不能用來修改集合。Enumerators can be used to read the data in the collection, but they cannot be used to modify the collection.

一開始,列舉程式位在集合中的第一個項目之前。Initially, the enumerator is positioned before the first element in the collection. 在此位置, 的傳回值GetCurrent為未定義。At this position, the return value of GetCurrent is undefined. 因此, 在呼叫MoveNext GetCurrent之前, 您必須呼叫, 將列舉值前移至集合的第一個元素。Therefore, you must call MoveNext to advance the enumerator to the first element of the collection before calling GetCurrent.

GetCurrent 會傳回相同的物件直到呼叫 MoveNextGetCurrent returns the same object until MoveNext is called. MoveNext將的傳回值GetCurrent設定為下一個元素。MoveNext sets the return value of GetCurrent to the next element.

如果MoveNext傳遞集合的結尾, 則列舉值會放置在集合中的最後一個元素之後false, MoveNext並傳回。If MoveNext passes the end of the collection, the enumerator is positioned after the last element in the collection and MoveNext returns false. 當列舉值在此位置時, 後續的呼叫MoveNext false也會傳回。When the enumerator is at this position, subsequent calls to MoveNext also return false. 如果最後一個呼叫MoveNext傳回GetCurrent , false則的傳回值會是未定義的。If the last call to MoveNext returned false, the return value of GetCurrent is undefined.

只要集合維持不變,列舉程式就持續有效。An enumerator remains valid as long as the collection remains unchanged. 如果對集合進行變更,例如加入、修改或刪除項目,列舉程式會永久失效,且其行為未定義。If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined.



執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(繼承來源 IDisposable)

傳回集合中位於列舉值目前位置的物件。Returns the object in the collection at the current position of the enumerator.


將列舉值往前推至下集合中的下一個項目。Advances the enumerator to the next element of the collection.


設定列舉值至它的初始位置,這是在集合中第一個項目之前。Sets the enumerator to its initial position, which is before the first element in the collection.