score:9

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.

http://download.microsoft.com/download/5/8/6/5868081c-68aa-40de-9a45-a3803d8134b8/standard_query_operators.doc

score:2

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.

score:5

Where filters, Select maps. Two totally different things.


Related Query

More Query from same tag