So I frequently run into this situation... where Do.Something(...) returns a null collection, like so:
Do.Something(...)
int[] returnArray = Do.Something(...); >
A foreach loop calls the GetEnumerator method. If the collection is null, this method call results in a NullReferenceException.
foreach
GetEnumerator
null
NullReferenceException
It is bad practice to return a null collection; your methods should return an empty collection instead.