Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add " character to a multi line string declaration in C#?

If I write something like this:

string s = @"...."......"; 

it doesn't work.


If I try this:

string s = @"...\"....."; 

it doesn't work either.

How can I add a " character to a multi line string declaration in C#?

like image 575
User Avatar asked Mar 23 '09 15:03

User


People also ask

How do I write a multi line string literal in C?

We can use string literal concatenation. Multiple string literals in a row are joined together: char* my_str = "Here is the first line." "Here is the second line."; But wait!

How do you write a multi line string?

Use triple quotes to create a multiline string It is the simplest method to let a long string split into different lines. You will need to enclose it with a pair of Triple quotes, one at the start and second in the end. Anything inside the enclosing Triple quotes will become part of one multiline string.

How do you add multiple lines to a string in C++?

Use the std::string Class to Declare Multiline String in C++ C++ allows multiple double-quoted string literals to be concatenated automatically in a statement. As a result, one might include any number of lines while initializing the string variable and keep the code more consistently readable.

Can a string contain multiple lines of text?

Raw StringsThey can span multiple lines without concatenation and they don't use escaped sequences. You can use backslashes or double quotes directly. For example, in Kotlin, in addition to regular string literals, you can use Raw Strings with three double quotes """ instead of just one.


1 Answers

Try this:

string s = @"...""....."; 
like image 188
mqp Avatar answered Sep 30 '22 20:09

mqp