Suppose that you have a lengthy string (> 80 characters) that you want to spread across multiple source lines, but don’t want to include any newline characters.
One option is to concatenate substrings:
string longString = "Lorem ipsum dolor sit amet, consectetur adipisicing" +
" elit, sed do eiusmod tempor incididunt ut labore et dolore magna" +
" aliqua. Ut enim ad minim veniam";
Is there a better way, or is this the best option?
Edit: By “best”, I mean easiest for the coder to read, write, and edit. For example, if you did want newlines, it’s very easy to look at:
string longString =
@"Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam";
I am wondering if there is something just as clean when you don’t want newlines.
I would use a variation of your method:
Here I start the string on the line after the equals sign so that they all line up, and I also make sure the space occurs at the end of the line (again, for alignment purposes).