Supports a simple ForEach-style iteration over a collection.
IEnumerator
[Visual Basic] Public Interface IEnumerator [C#] public interface IEnumerator [C++] public __gc __interface IEnumerator
[JScript] In JScript, you can use the interfaces in the NGWS frameworks, but you cannot define your own.
Class | Description |
---|---|
DirectoryEntryCollection.ChildEnumerator | Supports a simple ForEach-style iteration over a collection and defines enumerators, size, and synchronization methods. |
DirectoryEntryPropertyCollection.PropertyEnumerator | Supports a simple ForEach-style iteration over a collection and defines enumerators, size, and synchronization methods. |
EventLog.EntriesEnumerator | Holds an EventLog.EventLogEntryCollection that consists of the entries in an event log. |
MessageQueuesEnumerator | [To be supplied.] |
MessagesEnumerator | Provides forward only cursor semantics to enumerate the messages contained in a queue. Each instance of this object uses a separate cursor. |
SearchResults.ResultsEnumerator | [To be supplied.] |
SearchResultsPropertyCollection.SearchResultsPropertyEnumerator | [To be supplied.] |
SerializationInfoEnumerator | [To be supplied.] |
TextElementEnumerator | [To be supplied.] |
IEnumerator is the base interface for all enumerators.
The enumerator also does not have exclusive access to the collection, so multiple enumerators may have access to the same collection.
When an enumerator is instantiated, it takes a snapshot of the current state of the collection.
Two enumerators instantiated from the same collection at the same time may not have exactly the same snapshots of the collection.
Changes made to the collection, either directly or through another enumerator, would cause the snapshot to be out of sync and the enumerator to be invalidated. An invalid enumerator may cause Current or MoveNext to throw an exception.
The enumerator is initially positioned before the first element in the collection and it must be advanced before it is used.
Removing objects from the enumerator will remove them from the collection.
Namespace: System.Collections
Assembly: mscorlib.dll
IEnumerator Members | System.Collections Namespace | IEnumerable | ICollection