See Also: IEnumerator Members
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.