I find myself writing the following over and over:
if (myEnumerable != null) {
foreach (var element in myEnumerable) {
DoSomething(element);
}
}
It's tedious to check for NULL every time I want to enumerate, is there a better way? For instance, is there a way to override the enumerator to return "Enumerable.Empty" instead of NULL?