4

I have a string and I want to write it over multiple line, hover I don't want to write it the below way since it would be tedious

val = " lines 1 "
     + " lines +
     ....

any idea?

Aliaksandr Maksimau
  • 2,251
  • 12
  • 21
khaled alomar
  • 673
  • 4
  • 25

2 Answers2

9

You can try the following:

str tmp =
@"123
456
789";

Note the text is aligned all the way to the edge of the editor, otherwise those indentations/spaces will be included in the string.

If that not what you looking for, then maybe TextBuffer class will be suitable for your needs.

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
Aliaksandr Maksimau
  • 2,251
  • 12
  • 21
3

Try with a backslash at the end of the line like this

str tmp;
;

tmp = "123\
       456\
       789";

Note: The leading spaces in the lines are part of the string, so the result is not
"123456789" but "123 456 789"

Mohammad Yusuf
  • 16,554
  • 10
  • 50
  • 78
DAXaholic
  • 33,312
  • 6
  • 76
  • 74