Mono Class Library: System.Collections.ArrayList Overview | Members

System.Collections.ArrayList.Capacity Property

Gets or sets the number of elements that the current instance is capable of storing. [Edit]

public virtual int Capacity { set; get; }

Value

A int that specifies the number of elements that the current instance is capable of storing. [Edit]

Exceptions

TypeReason
ArgumentOutOfRangeExceptionArrayList.Capacity is set to a value that is less than the ArrayList.Count of the current instance. [Edit]

Remarks

Note: The ArrayList.Capacity of a ArrayList is the size of the internal array used to hold the elements of that list. When it is set, the internal array is reallocated to the specified value.

Operation
As described above.

If an attempt is made to set ArrayList.Capacity to a value less or equal to 0, it is set to the default capacity of 16.

If the ArrayList.Count of the current instance exceeds the ArrayList.Capacity of the current instance while adding elements to the current instance, the capacity of the list is doubled by automatically reallocating the internal array before copying the old elements and adding the new elements.

[Edit]

Requirements

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0