Sean Chambers Sean Chambers - 8 months ago 76
C# Question

The best way to get a count of IEnumerable<T>

Whats the best/easiest way to obtain a count of items within an IEnumerable collection without enumerating over all of the items in the collection?

Possible with LINQ or Lambda?

Answer Source

you will have to enumerate to get a count. Other constructs like the List keep a running count.