Strings are one of most frequent use data types in C#. Strings in C# are immutable means that once a string is created, it cannot be changed. No characters can be added or removed from it, nor can its length be changed.
The String object is immutable while StringBuilder object is mutable. Both String and StringBuilder are reference type. But String acts like a value type.
StringBuilder is located in the System.Text namespace.
The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object. Using the StringBuilder class can boost performance when concatenating many strings together in a loop.
The String object is immutable while StringBuilder object is mutable. Both String and StringBuilder are reference type. But String acts like a value type.
StringBuilder is located in the System.Text namespace.
The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object. Using the StringBuilder class can boost performance when concatenating many strings together in a loop.
The following table lists the methods you can use to modify the contents of a StringBuilder.
|
Method
|
Description
|
|
StringBuilder.Append
|
Appends information to the end of the current StringBuilder.
|
|
StringBuilder.AppendFormat
|
Replaces a format specifier passed in a string with formatted text.
|
|
StringBuilder.Insert
|
Inserts a string or object into the specified index of the current StringBuilder.
|
|
StringBuilder.Remove
|
Removes a specified number of characters from the current StringBuilder.
|
|
StringBuilder.Replace
|
Replaces a specified character at a specified index.
|


Ramzanali MominPosted Oct 15, 2018, 12:03 AM
Simple and good
Omid NasriPosted Oct 22, 2016, 5:38 PM
Good.
kalu singh raoPosted Jul 19, 2016, 5:01 AM
Nice...
Sumitha PatelPosted Aug 22, 2014, 6:54 AM
if i am going to use the APPEND Method in string program ,is String Builder class is mandatory to use or not
Tim BurgaPosted Jul 17, 2009, 3:00 PM
Are you planning to reproduce the entire MSDN documentation one class at a time?