What is the list size property in C #?

How to access List <> in size in C #? In an array, this is array.length, but what is the property of List <>?

+6
list c #
source share
3 answers

This is a Count property for a list and in almost any other collection class in the Framework. The Count property is also defined on the ICollection <T> interface.

+13
source share

If you want to know how many items are in the list, use the Count property.

int numElements = list.Count; 

On the other hand, if you want to know how many items the List<T> backup store stores, then use the Capacity property.

 int size = list.Capacity; 
+11
source share

The Count property will give you the number of objects in the list.

+3
source share

All Articles