StringBuilder class is the part of the C# string in the category of mutable string and it’s provide like a mutable strings (dynamically add the more character in given string). Mutable strings are also known as dynamic strings.

StringBuilder class provides a many methods which are used to manipulate the strings dynamically. 

There are some important methods related to StringBuilder class as

1.       Append() : which are used for an append a string

2.       AppendFormat(): which are used for an append a strings using a specific format

3.       Insert(): which are used for inserts a string at a specified position

4.       Remove(): which are used for removes the specified characters.

5.       Replace(): Replaces all instances of a character with a specified one.

6.       EnsureCapacity():it check the sufficient size. Etc.


And properties of its

Capacity, Length, MaxCapacity etc.

How create the StringBuilder class

·    StringBuilder strName=new StringBuilder()

Where strName is created as an empty string.

·    StringBuilder strName=new StringBuilder(“India”);

Where strName is created with a string “india”.


Note: The System.Text namespace contains the StringBuilder class.

  Modified On Sep-18-2014 01:23:54 PM

Leave Comment