Multiline Strings

Download c# eBook

Example

var multiLine = @"This is a 

multiline paragraph";

Output:

This is a

multiline paragraph

Live Demo on .NET Fiddle

Multi-line strings that contain double-quotes can also be escaped just as they were on a single line, because they are verbatim strings.

var multilineWithDoubleQuotes = @"I went to a city named

                        ""San Diego""

                      during summer vacation.";

Live Demo on .NET Fiddle

It should be noted that the spaces/tabulations at the start of lines 2 and 3 here are actually present in the value of the variable; check this question for possible solutions.

Stats

Contributors: 6
2016-08-09
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook