This question makes gross coercion; LINQ is actually very convenient in such cases - I discussed it here: Brute force (but lazy)
Just to expand some of the previous answers:
LINQ is usually created around deferred execution, which means that nothing happens before the result starts to repeat. This is usually done through an iterator block; consider the difference between the two:
static IEnumerable<T> Where(this IEnumerable<T> data, Func<T,bool> predicate) { foreach(T item in data) { if(predicate(item)) yield return item; } }
and
static IEnumerable<T> Where(this IEnumerable<T> data, Func<T,bool> predicate) { var list = new List<T>(); foreach(T item in data) { if(predicate(item)) list.Add(item); } return list; }
The difference is that the second version does all the work when you call Where , returning one result, where - how the second (through the magic of iterator blocks) only works when the enumerator calls MoveNext() . Iterator blocks are discussed in more detail in the free chapter of the C # <6> example in depth .
In general, the advantage of this is that it makes queries complex, especially important for database-based queries, but in the same way as for normal operation.
Note that even with iterator blocks, second exists; buffering. Consider Reverse() - no matter how you do it, to change the sequence, you first need to find the end of the sequence. Now consider that not all sequences end! Compare this with Where , Skip , Take , etc. - which can filter rows without buffering (simply by deleting elements).
A good example of using this in infinite sequence is this Fibonacci question , where we can use the unbuffered, deferred approach:
foreach (long i in Fibonacci().Take(10)) { Console.WriteLine(i); }
Without delayed execution, this will never end.