Intermediate C#
Q74 / 100

What is the difference between string and StringBuilder for performance?

Correct! Well done.

Incorrect.

The correct answer is B) string is immutable; repeated concatenation creates many objects. StringBuilder avoids this by mutating an internal buffer

B

Correct Answer

string is immutable; repeated concatenation creates many objects. StringBuilder avoids this by mutating an internal buffer

Explanation

string s = a + b + c creates two intermediate strings. var sb = new StringBuilder(); sb.Append(a); sb.Append(b); sb.Append(c); allocates one buffer.

Progress
74/100