Like a C # compiler compiling strings

Possible duplicate:
Does C # optimize string literal concatenation?

string foo = "bar1" + "bar2" + "bar3"; 

Does the C # compiler use the string.Concat method?

Then it would be better to use the + operator for readability.

+7
source share
1 answer

With literals, this is equivalent to:

 string foo = "bar1bar2bar3"; 

Concatenation is not performed - they are combined at compile time into a constant.

+3
source

All Articles