Passing an empty IEnumerable argument to a method
- by avance70
I have this method (simplified):
void DoSomething(IEnumerable<int> numbers);
And I invoke it like this:
DoSomething(condition==true?results:new List<int>());
The variable results is formed with a LINQ select condition (IEnumerable).
I was wondering is this List<int>() the best way (the fastest?) to pass an empty collection, or is new int[0] better? Or, something else would be faster, a Collection, etc.? In my example null wouldn't be ok.