O'Reilly logo

Pro LINQ: Language Integrated Query in C# 2008 by Joseph C. Rattz Jr.

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

Returning IEnumerable<T>, Yielding, and Deferred Queries

It is important to remember that while many of the Standard Query Operators are prototyped to return an IEnumerable<T>, and we think of IEnumerable<T> as a sequence, the operators are not actually returning the sequence at the time the operators are called. Instead, the operators return an object that when enumerated will yield an element from the sequence. It is during enumeration of the returned object that the query is actually performed and an element is yielded to the output sequence. In this way, the query is deferred.

In case you are unaware, when I use the term yield, I am referring to the C# 2.0 yield keyword that was added to the C# language to make writing enumerators easier. ...

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