The capacity of a List(Of T) is the number of elements that the List(Of T) can hold. As elements are added to a List(Of T), the capacity is automatically increased as required by reallocating the internal array.

If the size of the collection can be estimated, using the List(Of T)(Int32) constructor and specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the List(Of T).

The capacity can be decreased by calling the TrimExcess method or by setting the Capacity property explicitly. Decreasing the capacity reallocates memory and copies all the elements in the List(Of T).

The following code example demonstrates the default constructor of the List(Of T) generic class. The default constructor creates a list with the default capacity, as demonstrated by displaying the Capacity property.

The code example adds, inserts, and removes items, showing how the capacity changes as these methods are used.