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
實作

備註

語言的foreach和 For Each ... C# C# Visual Basic 中的下一個結構會隱藏枚舉器的複雜性。The C# foreach of the C# language and the For Each...Next construct in Visual Basic hides the complexity of enumerators. 建議使用 foreachFor Each...Next,而不是直接操作枚舉器。Instead 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> 中的第一個專案,然後再讀取 Current的值。You 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. 當列舉值處於此狀態時,MoveNext 的後續呼叫也會傳回 false 而且 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.

適用於