Most efficient way to concatenate strings?

Question :

Most efficient way to concatenate strings?,

Answer :

What’s the most efficient way to concatenate strings?

,

 the .NET Performance guru, had  on this very subject. It’s not as simple as one might suspect. The basic advice is this:

If your pattern looks like:

x = f1(...) + f2(...) + f3(...) + f4(...)

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

If your pattern looks like:

if (...) x += f1(...)
if (...) x += f2(...)
if (...) x += f3(...)
if (...) x += f4(...)

then you probably want StringBuilder.

comes from Eric Lippert where he describes the optimizations performed on one line + concatenations in a detailed manner.

Read More  Offsite backups

That’s the answer Most efficient way to concatenate strings?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you