Restriction

One of the most common query operations is obviously to filter out elements based on certain conditions. Those conditions can either be on a per-element basis (such as with the Where operator) or have a more global nature (as with Skip or Take). In essence, we’re talking here about horizontal partitioning where a given number of objects in the input sequence are filtered down to a subset. Those restriction operators don’t change the shape of the data and preserve the type of the input sequence.

Where

The first restriction operator is one we’re already familiar with. The Where operator evaluates a condition for each element in the input sequence, only retaining objects for which the condition evaluated to true. Two overloads exist: ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.