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>. 在此位置上,未定义 CurrentAt 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 在调用之前,返回相同的值 MoveNextCurrent 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.

适用于