tags:

views:

136

answers:

2

In the Essential C# 3.0 book, there is a part where it says:

"Projection using the select() method is very powerful. We already saw how to filter a collection vertically (reducing the number of items in the collection) using the Where() standard query operator. Now, via the Select() standard query operator, we can also reduce the collection horizontally (making fewer columns) or transform the data entirely. In combination,

Where() and Select() provide a means for extracting only the pieces of the original collection that are desirable for the current algorithm."

What does horizontally and vertically means in this case? Do these methods enumerate on a collection differently?

+7  A: 

No, they enumerate the collection alike.

If you think of a collection as a set of objects (rows), each with some properties (columns) like a database table. You could filter the results out by removing some rows (vertically) by specifying a condition using Where or remove a set of columns by Selecting a subset of properties (horizontally).

Mehrdad Afshari
Thanks. Now I got it.
Joan Venge
+4  A: 

Picture a table with rows and columns. The rows represent the vertical direction, while the columns represent the horizontal. From the context of the author's sentence it sounds like he uses vertically and horizontally to mean that a Where() clause will reduce the number of rows (results returned) while a Select() clause affects the number of columns.

Make sense?

Ahmad Mageed
Thanks. It makes sense. Mehrdad's example is pretty good too.
Joan Venge