O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required