Best way to break long strings in C# source code

It’s done at compile time. That’s exactly equivalent to “string1string2string3”.

Suppose you have:

string x = "string1string2string3"
string y = "string1" + "string2" + "string3"

The compiler will perform appropriate interning such that x and y refer to the same objects.

EDIT: There’s a lot of talk about StringBuilder in the answers and comments. Many developers seem to believe that string concatenation should always be done with StringBuilder. That’s an overgeneralisation – it’s worth understanding why StringBuilder is good in some situations, and not in others.

Leave a Comment

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş