What is the difference between Count and Count() in observable collections in C#?
I have noticed in the type ahead of Visual Studio for the ObservableCollection class I can choose either “.Count;” or “.Count();”. What is the difference? Not knowing this can get one in trouble, I think.
What is the difference between Count and Count() in observable collections in C#? I
Share
The
Count()is a LINQ extension. TheCountis a property inherited fromCollection<T>. The implementation of theCount()extension will know that your object is implementingICollection<T>, and so will just return the results of the property. You can use either one, the performance benefit of using the property are basically non-existent.