Retrieves or assigns the capacity of the current StringBuilder, which is the number of characters the current StringBuilder is capable of holding.
[Visual Basic] Public Property Capacity As Integer [C#] public int Capacity {get; set;} [C++] public: __property int get_Capacity(); public: __property void set_Capacity(int); [JScript] public function get Capacity() : int; public function set Capacity(int);
Read/write. This property retrieves or assigns the capacity of the current StringBuilder.
Exception Type | Condition |
---|---|
ArgumentException | if an attempt is made to assign a capacity that is less than the current capacity. |
The default capacity is 16. If a value is assigned that is greater than the current capacity, memory is allocated to allow the StringBuilder to grow.
StringBuilder Class | StringBuilder Members | System.Text Namespace