This documentation is archived and is not being maintained.

SortedList.Capacity Property

Gets or sets the capacity of the SortedList.

[Visual Basic]
Public Overridable Property Capacity As Integer
public virtual int Capacity {get; set;}
public: __property virtual int get_Capacity();
public: __property virtual void set_Capacity(int);
public function get Capacity() : int;
public function set Capacity(int);

Property Value

The number of elements that the SortedList can contain.


Exception Type Condition
ArgumentOutOfRangeException The value assigned is less than the current number of elements in the SortedList.


If the number of elements added to the list reaches the current capacity, the capacity is automatically doubled.

When Capacity is set, the internal arrays are reallocated to accommodate the new capacity.

TrimToSize can also be used to reduce the capacity of the SortedList.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

SortedList Class | SortedList Members | System.Collections Namespace | TrimToSize