When implemented by a class, returns an enumerator which can be used to iterate through a collection.
[Visual Basic] Function GetEnumerator() As IEnumerator [C#] IEnumerator GetEnumerator(); [C++] IEnumerator* GetEnumerator() = 0; [JScript] function GetEnumerator() : IEnumerator;
An IEnumerator, which can be used to iterate through the collection.
When an enumerator is instantiated, it takes a snapshot of the current state of the collection. The enumerator also does not have exclusive access to the collection and multiple enumerators may have access to the same collection at the same time. Therefore, any changes made to the collection, either directly or through another enumerator, may cause Current or MoveNext to throw an exception.
Two enumerators instantiated from the same collection at the same time may not have exactly the same snapshots of the collection.
Removing objects from the enumerator will remove them from the collection.
Notes to Implementers:
The enumerator must be initially positioned before the first element of the collection and must be advanced by the caller of the implementation before use.
IEnumerable Interface | IEnumerable Members | System.Collections Namespace | IEnumerator