Query operators are methods that work with a sequence of data and perform some task based on the data. They are created as extension methods on the
IEnumerable<T> interface, which is the interface implemented by classes that hold enumerable data. For example, arrays and the classes in the
System.Collections and System.Collections.Generic namespaces all implement IEnumerable<T>. In
The Ins and Outs of Query Operators we looked at how to create your own query operator that, once created,
can be applied to any enumerable object.
While it is possible to create your own query operators, the good news is that the .NET Framework already ships with a bevy of useful query operators. These query operators
are referred to as the standard query operators and are one of the primary pieces of LINQ. The standard query operators include functionality for aggregating sequences
of data, concatenating two sequences, converting sequences from one type to another, and splicing out a particular element from the enumeration. There are also standard
query operators for generating new sequences, grouping and joining sequences, ordering the elements in sequences, filtering the data in a sequence, and partitioning the
sequence.
All together, there are more than 40 standard query operators. This article explores some of the more germane ones, giving examples of the standard query operator in use and
examining its underlying source code. There are also several demos included in the download available at the end of the article. Read on to learn more!
Read More >