enumerator
The object that walks a sequence, with MoveNext to advance and Current to read the item it is on.
In more detail
foreach asks a collection for its enumerator and calls MoveNext each pass. You rarely use it directly.
Related terms
- foreach — The C# loop that asks a collection for its enumerator and hands you one item at a time.
- iterator — An object that produces the items of a sequence one at a time, on request, instead of all at once.
- IEnumerable<T> — The .NET interface for any sequence you can loop over one item at a time, the basis of foreach and in-memory LINQ.
Taught in
- The C# Language: Types, Variables, and Flow Control — Modern .NET Core, C# & Enterprise Microservices
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices