System.Collections.IEnumerator.Reset Method

Sets the enumerator to its initial position, which is before the first element in the collection.

Syntax

public void Reset ()

Exceptions

TypeReason
InvalidOperationExceptionThe collection was modified after the enumerator was instantiated.

Remarks

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 the next call to the IEnumerator.MoveNext or IEnumerator.Reset method throws an InvalidOperationException.

The IEnumerator.Reset method is provided for COM interoperability. It does not necessarily need to be implemented; instead, the implementer can simply throw a NotSupportedException.

Requirements

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0