What is the difference between Count and Count () in observable collections in C #?

What is the difference between Count and Count () in observable collections in C #? I noticed that in the class preceding Visual Studio for the ObservableCollection class, I can choose either ".Count;" or ".Count ();". What is the difference? I do not think that this can be a problem.

+4
source share
3 answers

Count() is a LINQ extension. Count is a property inherited from Collection<T> . An implementation of the Count() extension will know that your object implements ICollection<T> , and therefore simply returns the results of the property. You can use one of them, the advantage of using this property in principle does not exist.

+5
source

It doesn't really matter, but Count () is available for more types.

Not all collection types have the Count property. For example, IEnumerable does not. The LINQ Count () method works with all of these collection types, using the Count property or a loop through the collection to count items.

+2
source

Count - property of the ObservableCollection, Count () is the extension method from linq.

0
source

All Articles