Take the 2-minute tour ×

What's the most efficient way to concatenate strings?

share|improve this question
add comment

12 Answers

up vote 56 down vote accepted

The StringBuilder.Append() method is much better than using the + operator. But I've found that, when the concatenations are less than 1000, String.Join() is even more efficient than StringBuilder.

StringBuilder sb = new StringBuilder();


share|improve this answer
Isn't the 'ToString' call on 'someString' unnecessary? Unless 'someString' is really an int, and it's a big lying liar. ;) –  Sarah Vessels Jun 25 '09 at 13:44
funny, but good point :) –  TheEmirOfGroofunkistan Jun 30 '09 at 20:28
show 4 more comments


If your pattern looks like:


that's one concat and it's zippy, StringBuilder probably won't help.

If your pattern looks like:


then you probably want StringBuilder.

share|improve this answer
add comment

From Chinh Do - StringBuilder is not always faster:

Rules of Thumb





share|improve this answer
afaik @ only turns off escape sequences processing. msdn.microsoft.com/en-us/library/362314fe.aspx agree –  abatishchev Jul 18 '10 at 20:11
add comment

There are 5 types of string concatenations:

  1. using plus (+) symbol.
  2. using string.Concat().
  3. using string.Format().
  4. using string.Append().
  5. using stringBuilder.

In an experiment, it has been proved that string.Concat() is the best way to approach if the strings are less than 1000(approximately) and if the strings are more than 1000 then stringBuilder should be used.

For more information, check this site.

share|improve this answer
i am new to .net, while referring this question i also got this link through google search. so i just forwarded here thinking it may help others. –  Mr_Green Sep 4 '12 at 8:40
1000? 1000 strings, chars, carrots? –  Matthew Canty Oct 11 '13 at 9:16
@MatthewCanty carrots.. carrots because I am no longer working on this field (.NET). you can edit my post or add a post which explains more clearly than mine or downvote my post or better one is to comment here so that I can improve it. :) –  Mr_Green Oct 11 '13 at 9:22
btw, I made the statement as strings in my post -- if the strings are less than 1000. –  Mr_Green Oct 11 '13 at 9:28
Could be a 1000 strings or a string 1000 characters long... –  Matthew Canty Oct 11 '13 at 16:33
add comment



share|improve this answer
I've been recommending the use of string.format over string + string for years to people I've worked with. I think the readability advantages are an additional advantage beyond the performance benefit. –  Scott A. Lawrence Nov 14 '08 at 18:38
add comment

From this MSDN article:



Simple and sound, if - I repeat - you decide to trust MSDN.

share|improve this answer
add comment

The most efficient is to use StringBuilder, like so:

StringBuilder sb = new StringBuilder();
String strResult = sb.ToString();


share|improve this answer
add comment


share|improve this answer
add comment



share|improve this answer
add comment



How to: Concatenate Multiple Strings (C# Programming Guide)

share|improve this answer
add comment



share|improve this answer
add comment


share|improve this answer
add comment

Your Answer


