Junior Collections

What is the difference between Count and Capacity in List<T>?

Property Meaning

Count Number of elements currently in the list

Capacit

Total allocated slots (memory reserved)

Example:

Console.WriteLine($"Count: {list.Count}, Capacity:

{list.Capacity}");

More from C# Programming Tutorial

All questions for this course