I have a List<String> myList
.
I want to take the first 10 items in this list that match some criteria (let's say .Contains("a")
, for example).
I have:
Var results = myList.Where(o=>o.Contains("a")).Take(10);
Which works fine, but has LINQ performed a Where
to retrieve all of the items meeting this criteria and then only took the first 10 of those? Or will this be compiled in a way that the entire LINQ statement is taken into consideration (i.e. it will perform the Where
but only up until it reaches 10 items)?