Sean Chambers Sean Chambers - 15 days ago 9
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

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