The collection was modified after the enumerator was instantiated.
Remarks
Note: When the current instance is constructed
or after IEnumerator.Reset is called, the current instance
is positioned immediately before the first element of the collection, use IEnumerator.MoveNext to position the current instance
over the first element of the collection.
Operation
A call to
IEnumerator.Reset is required to position
the current instance immediately before the first element of the collection.
If elements are added, removed, or repositioned in the collection
after the current instance was instantiated, it is required that
a call to IEnumerator.Reset throw a InvalidOperationException.
Note to Inheritors
A call to IEnumerator.Reset can involve taking a new snapshot of the
collection or simply moving to the beginning of the collection. The preferred
implementation is to simply move the current instance to
the beginning of the collection, before the first
element. This invalidates the current instance
if the collection has been modified since the current instance was
constructed, which is consistent with IEnumerator.MoveNext and IEnumerator.Current.
Usage
Use the IEnumerator.MoveNext method to check if the current
instance is positioned immediately past the last element of the collection, and
to position it over the next element if it is not already past the last element
of the collection.