You can read all the C# performance tips from the following links,
In this blog, we will do benchmarking for List.Count() which is a method and List.Count which is a property.
- List<string> strs = new List<string>() { "Akshay", "Patel", "Panth", "Patel" };
- Stopwatch watch = new Stopwatch();
List.Count()
- watch.Start();
- int count = strs.Count();
- Console.WriteLine("Count()-{0}", watch.Elapsed);
List.Count
- watch.Restart();
- int count1 = strs.Count;
- Console.WriteLine("Count - {0}", watch.Elapsed);
Result
Thus, as we can see, whenever we want to get the count of a list, we should use the List.Count property.