If I have a list of items (e.g. List<string> items) in C#, I can use both:
items.Count()
and
items.Count
to get the total number of items. Is there a reason for them both being available? Why not just have the method .Count()?
I notice that if I filter the list (and and end up with an IEnumerable<string>):
items.Distinct().Count()
then .Count() has to be used. So why does List<string> allow .Count at all?
Because one is an (LINQ) extension method on System.Linq.Enumerable and the other is a property on the class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With