C# StringBuilder Capacity

Description

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

Syntax

StringBuilder.Capacity has the following syntax.


public int Capacity { get; set; }

Example

The following example demonstrates the Capacity property.


/*from  www.  j ava 2s.  com*/
using System;
using System.Text;

class Sample 
{
    public static void Main() 
    {
        StringBuilder sb1 = new StringBuilder("abc");
        Console.WriteLine(sb1.Capacity);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding