Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IEnumerable without data

Tags:

c#

.net

If I have a method or a property that returns an IEnumerable<SomeType> that leads to no data, is it more efficient to return an empty array new SomeType[0] or is it better to return an empty list new List<SomeType>() or is there an even better solution (IMO building an own type with generics could be such a solution but it seems to me a little bit overkill)?

The array is my favorite but what do you think about this?

like image 296
HCL Avatar asked Jul 07 '10 09:07

HCL


1 Answers

Return Enumerable.Empty<T>().

like image 71
mmx Avatar answered Oct 03 '22 16:10

mmx