Question: C# code:

```
string first = "A"; 
first += "B"; 
first += "C";
string second = "D" + "E" + "F";

```

Generated IL code:

```
.locals init ([0] string first,
           [1] string second)
  IL_0000:  nop
  IL_0001:  ldstr      "A"
  IL_0006:  stloc.0
  IL_0007:  ldloc.0
  IL_0008:  ldstr      "B"
  IL_000d:  call       string [mscorlib]System.String::Concat(string,
                                                              string)
  IL_0012:  stloc.0
  IL_0013:  ldloc.0
  IL_0014:  ldstr      "C"
  IL_0019:  call       string [mscorlib]System.String::Concat(string,
                                                              string)
  IL_001e:  stloc.0
  IL_001f:  ldstr      "DEF"
  IL_0024:  stloc.1
  IL_0025:  ret

```

It is obvious that the in-line concatenation is a bit more efficient because it calls ldstr only once, but are there any other differences (for instance string objects created in memory?)

Thanks

Answer: 
In the line-by-line case, the compiler does not have an optimization to notice that `line` has a value that can be known at compile time at every point. In the single-line case, it does have that optimization.

I suspect only members of the C# compiler team can tell you with certainty why they did not optimize the first case, though I suspect it's due to the relative complexity of analyzing multiple lines of code compared to the relative benefit to C# programmers.
For constants it is dup of [C# Compile-Time Concatenation For String Constants](https://stackoverflow.com/questions/1764700/c-sharp-compile-time-concatenation-for-string-constants) (merges string constants).

Otherwise use StringBuilder and be happy.