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

Source Generators

Source generators comprise our first big category of standard query operators. Although different source objects can be LINQ-enabled (for example, by implementing IEnumerable<T> for local query execution or by implementing IQueryable<T> for remote query execution; for example, as used in LINQ to SQL), it sometimes makes sense to create a sequence on-the-fly.

All the methods discussed here live on the Enumerable type and provide a means to generate a source without persisting it in memory, thanks to lazy evaluation. Obviously, you can also use array, lists, or other collection types as in-memory data sources, but with immediate memory-allocation needs.

Range

The first source generator is called Range and produces Int32 values ...

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