When to use StringBuilder?

Shiraz Bhaiji picture Shiraz Bhaiji · Dec 1, 2009 · Viewed 38k times · Source

I understand the benefits of StringBuilder.

But if I want to concatenate 2 strings, then I assume that it is better (faster) to do it without StringBuilder. Is this correct?

At what point (number of strings) does it become better to use StringBuilder?

Answer

Alex Bagnolini picture Alex Bagnolini · Dec 1, 2009

I warmly suggest you to read The Sad Tragedy of Micro-Optimization Theater, by Jeff Atwood.

It treats Simple Concatenation vs. StringBuilder vs. other methods.

Now, if you want to see some numbers and graphs, follow the link ;)