String vs. StringBuilder

Yes, the performance difference is significant. See the KB article “How to improve string concatenation performance in Visual C#”.

I have always tried to code for clarity first, and then optimize for performance later. That’s much easier than doing it the other way around! However, having seen the enormous performance difference in my applications between the two, I now think about it a little more carefully.

Luckily, it’s relatively straightforward to run performance analysis on your code to see where you’re spending the time, and then to modify it to use StringBuilder where needed.

Leave a Comment