Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0035 Verbatim string literal

A verbatim string literal starts with @ and doesn't escape the chars. The following code rewrites the path in a verbatim string. using System; class Program { static void Main(string[] args) { string path = @"c:\a\b\c\d.exe"; Console.WriteLine(path); } } The output: c:\a\b\c\d.exe To use double quotes in a verbatim string: using System; class Program { static void Main(string[] args) { string str = @"This is a ""test"" from rntsoft.com"; Console.WriteLine(str); } } The output: This is a "test" from rntsoft.com