Sets the capacity of the ArrayList to the actual number of elements in it.
[Visual Basic] Overridable Public Sub TrimToSize() [C#] public virtual void TrimToSize(); [C++] public: virtual void TrimToSize(); [JScript] public function TrimToSize();
None.
Exception Type | Condition |
---|---|
NotSupportedException | The ArrayList is read-only.
-or- The ArrayList has a fixed size. |
This method can be overridden by a derived class.
This method can be used to minimize a list's memory overhead if no new elements would be added to the list.
To completely clear all elements in a list, call the Clear method before calling TrimToSize.
ArrayList Class | ArrayList Members | System.Collections Namespace | Clear | TrimToSize | Capacity | Count