String Concatenation Best Practices

c#, string-concatenation, string-formatting

Solution

The "best practice" should be the thing that makes your code the most readable and maintanable. The performance difference between concatenating strings versus using `string.Format` versus using a `StringBuilder` is so small that it's essentially irrelevant.

Problem

Trying to determine if it's a better practice to use string.Format in place of concatenating strings and if so, why is this? Also, are their advantages/disadvantages to one or the other that I should be aware of? This: ``` string foo = "I" + " am " + " a " + " string."; ``` or: ``` string bar = string.Format("{0} am a {1}.", "I", "string"); ``` Obviously oversimplified examples, just wanting to be clear.

Original source

Related problems