Difference Between String and Stringbuilder in C#

String

The string is immutable, Immutable means if you create a string object then you cannot modify it and It always creates a new object of string type in memory.

Example

string strMyValue = "Hello Visitor";
// create a new string instance instead of changing the old one
strMyValue += "How Are";
strMyValue += "You ??";

StringBuilder

StringBuilder is mutable, which means if create a string builder object then you can perform any operation like insert, replace, or append without creating a new instance every time. it will update the string in one place in memory and doesn't create new space in memory.

Example

StringBuilder sbMyValue = new StringBuilder("");
sbMyValue.Append("Hello Visitor");
sbMyValue.Append("How Are You ??");
string strMyValue = sbMyValue.ToString();