What’s the best way to create multi-line string in C#?
I know the following methods:
Using StringBuilder
var result = new StringBuilder().AppendLine("one").AppenLine("two").ToString()
looks too verbose.
Using @
var result = @"one
two"
looks ugly and badly formatted.
What about this:
It’s a bit painful and possibly an overkill, but it gives the possibility to preserve the lines separation in your code.
To improve things a little, you could use an helper method: