Gets or sets the capacity of the SortedList.
[Visual Basic] Overridable Public Property Capacity As Integer [C#] public int Capacity {virtual get; virtual set;} [C++] public: __property virtual int get_Capacity(); public: __property virtual void set_Capacity(int); [JScript] public function get Capacity() : int; public function set Capacity(int);
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. |
When adding elements to the list and the number of elements exceeds the capacity, the capacity is 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.
SortedList Class | SortedList Members | System.Collections Namespace | TrimToSize