3 ms·
It depends on what you do, and the underlying code can be pretty smart. But it can also be pretty dumb. The main difference is that if you use .Where(P).Take(X
by henrikschroder 7y ago
It depends on what you do, and the underlying code can be pretty smart. But it can also be pretty dumb.
The main difference is that if you use .Where(P).Take(X), you're actually generating a new enumerator, a new coroutine, and that code doesn't get called until you actually enumerate it.
But if you write your for/if loop, you run the code immediately, you go through the source array, run the predicate on each item, until you have your X items, and then you return a new array with those elements.