Accepted answer

Where and Select certainly do not achieve the same thing.

Where filters the enumerable based on a predicate. The result of calling Where on IEnumerable<T> is IEnumerable<T>.

Select is a projection - it allows you to map the enumerable, for example to select only a subset of the properties of the enumerated type, or construct a different object entirely based upon values of the enumerated type.

Both where and select are at least O(n) - since each item in the enumeration will have to be visited to perform the projection or the filter.

The following document on the Standard Query Operators is a great reference.


Compare how the background code in theory would work:

// Where
foreach(var x in items)
    if (x.PropertyToFilterOn == filterValue)
        yield return x;

// Select
foreach (var x in items)
    yield return selector(x);

So mind you, the performance difference is based on the complexity of the given selector delegate. But as others have said, they serve different purposes.


Where filters, Select maps. Two totally different things.

Related Query

More Query from same tag