IEnumerable<T>
and IEnumerator<T>
Recap
To set the scene, we need to refresh our knowledge of the IEnumerable<T>
interface and its little brother, IEnumerator<T>
. The LINQ to Objects standard query operators are implemented as extension methods on the former interface, meaning that any query expressions can target any enumerable sequence. Because collection types implement this interface, this makes LINQ to Objects available for all of those (including arrays).
The IEnumerable<T>
interface basically provides the capability to request an enumerator, which acts like a cursor over a sequence of objects of type T
. Multiple enumerators can be active simultaneously, each with its own cursor into the underlying sequence:
Each enumerator is represented ...
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.