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#?
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!
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.
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.
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.
Try this:
string s = @"..."".....";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With