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

Projection Using the Select Clause

Now that we’ve identified the query sources, we can start operating on the data they provide. Although you might think of filtering and ordering as the first kind of operations you want to perform, we’ll start from the end. Every query expression in C# needs to end either by a select clause or a group by clause. The former operation is the simplest to explain, so we start from there.

Identity Projection

The most trivial projection possible doesn’t do any transformation on the input data and is called the identity projection, after the identity function. An example is shown here:

var nums = new List<int> { 1, 2, 3, 4, 5 };var res = from n in nums          select n;

This produces ...

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