Mono Class Library: System.Collections Namespace

System.Collections.IEnumerator

Implemented by classes that support a simple iteration over a collection. [Edit]

See Also: IEnumerator Members

[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.Guid("496B0ABF-CDEE-11D3-88E8-00902754C43A")]
public interface IEnumerator

Remarks

Note:

IEnumerator contains the IEnumerator.MoveNext and IEnumerator.Reset methods and the IEnumerator.Current property. The consumer of an object should call these methods or use this property when iterating over or reading the elements of a collection.

When an enumerator is instantiated or a call is made to IEnumerator.Reset, the enumerator is positioned immediately before the first element of the collection and a snapshot of the collection is taken. When the enumerator is in this position, a call to IEnumerator.MoveNext is necessary before reading IEnumerator.Current from the collection. If changes are made to the collection (such as adding, repositioning, or deleting elements) the snapshot can get out of sync, causing the enumerator to throw a InvalidOperationException if IEnumerator.MoveNext or IEnumerator.Reset are invoked. Two enumerators instantiated from the same collection at the same time can have different snapshots of the collection.

Enumerators are intended to be used only to read data in the collection.

An enumerator does not have exclusive access to the collection for which it was instantiated.

[Edit]

Requirements

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