Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.