C# – Difference between String and Stringbuilder in C#

Here i will make a case for what’s difference between string and stringbuilder in c# mistreatment asp.net.

String is immutable. immutable means that once we have a tendency to produce string object we tend to cannot modify. Any operation like insert, replace or append happened to vary string merely it’ll discard the recent value and it’ll produce new instance in memory to carry the new worth..


string strNmae = "Pawan";
// create a new string instance instead of changing the old one
str += "Kumar";
str += "Shukla";

String builder is mutable it means that once we tend to produce string builder object we can perform any operation like insert, replace or append without making new instance for every time.

StringBuilder sb = new StringBuilder(“”);
string strFullName = sb.ToString();


  1. It’s an immutable
  2. It’s mutable
  3. Performance wise string is slow because every time it will create new instance
  4. Performance wise stringbuilder is high because it will use same instance of object to perform any action


  1. In string we don’t have append keyword
  2. In StringBuilder we can use append keyword
  3. String belongs to System namespace
  4. Stringbuilder belongs to System.Text namespace


Leave a Reply

Your email address will not be published. Required fields are marked *