Bewerken

Share via


ArraySegment<T>.Enumerator Struct

Definition

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)

Type Parameters

T
Inheritance
ArraySegment<T>.Enumerator
Implements

Remarks

The C# foreach of the C# language and the For Each...Next construct in Visual Basic hides the complexity of enumerators. Instead of directly manipulating the enumerator, using foreach or For Each...Next is recommended.

Initially, the enumerator is positioned before the first element in the ArraySegment<T>. At this position, Current is undefined. You must call MoveNext to advance the enumerator to the first item in the ArraySegment<T> before reading the value of Current.

Current returns the same value until MoveNext is called. MoveNext sets Current to the next item in the ArraySegment<T>.

If MoveNext passes the end of the ArraySegment<T>, MoveNext returns false. When the enumerator is at this state, subsequent calls to MoveNext also return false and Current is undefined. You cannot set Current to the first item in the ArraySegment<T> again; you must create a new enumerator instance instead.

Properties

Current

Gets a reference to the item at the current position of the enumerator.

Methods

Dispose()

Releases all resources used by this enumerator instance.

MoveNext()

Advances the enumerator to the next element of the ArraySegment<T>.

Explicit Interface Implementations

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.

Applies to