This project has moved and is read-only. For the latest updates, please go here.

Multiline Strings

Feb 24, 2011 at 3:26 AM

Is there any way to do multiline strings without concatenating them together? I am really looking for something like heredocs from Perl or PHP.





Feb 26, 2011 at 7:56 PM

Yes there is, you can put a backslash at the end of every line.  For example:

var x = "blah blah\
blah blah\
more blah\
end of blah";
Feb 27, 2011 at 2:20 AM

I tried that and got a syntax error, I'll have to try it again on Monday and see what the exact error was.

Feb 27, 2011 at 10:24 PM

I just tried it in the silverlight console and it worked fine, however I should note that newlines are not preserved.  Add \r\n to the end of every line if you want to preserve newlines.

Feb 28, 2011 at 1:04 AM

that must be it then, i will try adding the newline char to my strings.