Careful with those enumerables
Careful with those enumerablesEver since .Net 2.0 introduced the
yieldkeyword for creating enumerators, and even more after the introduction of LINQ in C# 3.0, I've seen more and more APIs returnIEnumerable<T>instead ofIList<T>orICollection<T>or their older cousins theArrayListand the array object.That makes sense most of the time, especially for collections that aren't meant to be modified, and choosing between those different return types is not what I'm about to discuss here. You can find endless articles and threads about that.
via devlicio.us
I'm a big sinner when it comes to IEnumerable. Need to remember that lazy evaluation can lead to unexpected side-effects.