System.Collections.Specialized.StringEnumerator.MoveNext Method

Advances the enumerator to the next element of the collection.

Syntax

public bool MoveNext ()

Returns

true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.

Remarks

After an enumerator is created or after a StringEnumerator.Reset is called, an enumerator is positioned before the first element of the collection, and the first call to StringEnumerator.MoveNext moves the enumerator over the first element of the collection.

If StringEnumerator.MoveNext passes the end of the collection, the enumerator is positioned after the last element in the collection and StringEnumerator.MoveNext returns false. When the enumerator is at this position, subsequent calls to StringEnumerator.MoveNext also return false until StringEnumerator.Reset is called.

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 IEnumerator.MoveNext or IEnumerator.Reset throws an InvalidOperationException. If the collection is modified between IEnumerator.MoveNext and IEnumerator.Current, IEnumerator.Current returns the element that it is set to, even if the enumerator is already invalidated.

Requirements

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