Escaping special symbols in string literals

suggest change

Backslash

// The filename will be c:\myfile.txt in both cases
string filename = "c:\\myfile.txt";
string filename = @"c:\myfile.txt";

The second example uses a verbatim string literal, which doesn’t treat the backslash as an escape character.

Quotes

string text = "\"Hello World!\", said the quick brown fox.";
string verbatimText = @"""Hello World!"", said the quick brown fox.";

Both variables will contain the same text.

“Hello World!”, said the quick brown fox.

Newlines

Verbatim string literals can contain newlines:

string text = "Hello\r\nWorld!";
string verbatimText = @"Hello
World!";

Both variables will contain the same text.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


String Escape Sequences:
* Escaping special symbols in string literals

Table Of Contents
15 String Escape Sequences
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script