Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string is immutable and stringbuilder is mutable

Tags:

.net

can any one explain with examples


Related Discussion: Most efficient way to concatenate strings?

like image 322
peter Avatar asked Mar 22 '26 18:03

peter


1 Answers

string s = "a";

s += "b"; // this will create a new string object

StringBuilder sb = new StringBuild();
sb.Append("a");
sb.Append("b"); // appends to existing StringBuilder
like image 120
Brian Rasmussen Avatar answered Mar 24 '26 09:03

Brian Rasmussen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!