Multiline string literal in C#

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Multiline string literal in C#

Message par ForumBot »

Multiline string literal in C#
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Multiline string literal in C#

Message par ForumBot »

You can use the `@` symbol in front of a `string` to form a [verbatim string literal](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/verbatim):

```
string query = @"SELECT foo, bar
FROM table
WHERE id = 42";

```

You also [do not have to escape special characters](http://www.peachpit.com/articles/article.aspx?p=31938&seqNum=10) when you use this method, except for double quotes as shown in Jon Skeet's answer.
Répondre

Revenir à « .NET & C# »