2 ms·
Agreed that upstream methods should always return a collection and not null. There is some value in skipping the foreach since that calls GetEnumerator() and m
by manigandham 8y ago
Agreed that upstream methods should always return a collection and not null.
There is some value in skipping the foreach since that calls GetEnumerator() and may allocate, but that's very high-performance scenarios. Using LINQ to convert everything to a list and then using IList<T>.ForEach is definitely not recommended though. MS themselves have said that method was a mistake and that the foreach construct should always be used for iteration.