The element in the collection over which the current instance is positioned.
Type Reason InvalidOperationException The current instance is positioned before the first element or after the last element of the collection.
The collection was modified after the current instance was instantiated.
After an enumerator is created or after the IEnumerator.Reset method is called, the IEnumerator.MoveNext method must be called to advance the enumerator to the first element of the collection before reading the value of the IEnumerator.Current property; otherwise, IEnumerator.Current is undefined.
IEnumerator.Current also throws an exception if the last call to IEnumerator.MoveNext returned false, which indicates the end of the collection.
IEnumerator.Current does not move the position of the enumerator, and consecutive calls to IEnumerator.Current return the same object until either IEnumerator.MoveNext or IEnumerator.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.