score:8

Accepted answer
  1. No, the Select is not necesssary if you are not actually transforming the returned type.

  2. In this case, the ordering of the method calls could have an impact on performance. Sorting all the objects before filtering is sure to take longer than filtering and then sorting a smaller data set.

score:5

The .Select is unnecessary in this case because .Cast already guarantees that you're working with IEnumerable<string>.

The ordering of .OrderBy and .Where doesn't affect the results of the query, but in general if you use .Where first you'll get better performance because there will be fewer elements to sort.


Related Articles