Share via


Capacity Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets or sets the maximum number of characters that can be contained in the memory allocated by the current instance.

Namespace:  System.Text
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Property Capacity As Integer
public int Capacity { get; set; }
public:
property int Capacity {
    int get ();
    void set (int value);
}
member Capacity : int with get, set
function get Capacity () : int
function set Capacity (value : int)

Property Value

Type: System. . :: . .Int32
The maximum number of characters that can be contained in the memory allocated by the current instance.

Remarks

Capacity does not affect the string value of the current instance. Capacity can be decreased as long as it is not less than Length.

The StringBuilder dynamically allocates more space when required and increases Capacity accordingly. For performance reasons, a StringBuilder might allocate more memory than needed. The amount of memory allocated is implementation-specific.

.NET Framework Security

See Also

Reference

StringBuilder Class

System.Text Namespace