ArraySegment<T>.Enumerator 結構

定義

提供 ArraySegment<T> 元素的列舉程式。Provides an enumerator for the elements of an ArraySegment<T>.

public: value class ArraySegment<T>::Enumerator : System::Collections::Generic::IEnumerator<T>
public struct ArraySegment<T>.Enumerator : System.Collections.Generic.IEnumerator<T>
type ArraySegment<'T>.Enumerator = struct
    interface IEnumerator<'T>
    interface IEnumerator
    interface IDisposable
Public Structure ArraySegment(Of T).Enumerator
Implements IEnumerator(Of T)

類型參數

T
繼承
ArraySegment<T>.Enumerator
實作

備註

C # 語言的 c # foreachFor Each 的 Visual Basic 中的下一個結構會隱藏枚舉器的複雜度。The C# foreach of the C# language and the For Each...Next construct in Visual Basic hides the complexity of enumerators. 建議使用或,而不是直接操作枚舉器 foreach For Each...NextInstead of directly manipulating the enumerator, using foreach or For Each...Next is recommended.

一開始,列舉值會放置在中的第一個元素之前 ArraySegment<T>Initially, the enumerator is positioned before the first element in the ArraySegment<T>. 在這個位置上,Current 並未定義。At this position, Current is undefined. 在讀取的值之前,您必須先呼叫,將 MoveNext 列舉值前移至中的第一個專案 ArraySegment<T> CurrentYou must call MoveNext to advance the enumerator to the first item in the ArraySegment<T> before reading the value of Current.

Current 傳回相同的值,直到 MoveNext 呼叫為止。Current returns the same value until MoveNext is called. MoveNext 將設定 Current 為中的下一個專案 ArraySegment<T>MoveNext sets Current to the next item in the ArraySegment<T>.

如果 MoveNext 傳遞的結尾,則會傳回 ArraySegment<T> MoveNext falseIf MoveNext passes the end of the ArraySegment<T>, MoveNext returns false. 當列舉值處於這種狀態時,後續呼叫 MoveNextfalse 會傳回,而且 Current 未定義。When the enumerator is at this state, subsequent calls to MoveNext also return false and Current is undefined. 您不能 Current 再次將設定為中的第一個專案 ArraySegment<T> ; 您必須改為建立新的列舉值實例。You cannot set Current to the first item in the ArraySegment<T> again; you must create a new enumerator instance instead.

屬性

Current

取得位於目前列舉值位置的項目參考。Gets a reference to the item at the current position of the enumerator.

方法

Dispose()

釋放此列舉程式執行個體所使用的所有資源。Releases all resources used by this enumerator instance.

MoveNext()

將列舉值前移至 ArraySegment<T> 的下一個項目。Advances the enumerator to the next element of the ArraySegment<T>.

明確介面實作

IEnumerator.Current

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

IEnumerator.Reset()

將列舉程式設定至其初始位置,也就是陣列區段中的第一個元素之前。Sets the enumerator to its initial position, which is before the first element in the array segment.

適用於