I know generally empty List is more prefer than NULL. But I am going to return NULL, for mainly two reasons
If you need to be able to retrieve all of the elements in the case of it not being empty, then some of the answers here won't work, because the call to Any() on a non-rewindable enumerable will "forget" an element.
You could take a different approach and turn nulls into empties:
bool didSomething = false;
foreach(var element in someEnumeration ?? Enumerable.Empty())
{
//some sensible thing to do on element...
didSomething = true;
}
if(!didSomething)
{
//handle the fact that it was null or empty (without caring which).
}
Likewise (someEnumeration ?? Enumerable.Empty etc. can be used.