Search This Blog

Tuesday, January 29, 2013

Verbatim String Literals (C#)

C# > Verbatim String Literals 

In a verbatim string literal, the characters between the delimiters are interpreted verbatim, the only exception being a quote-escape-sequence.

Suppose you want to set a string as following:

string path = "C:\\Programs\\MyProgram\\My.exe";


You can use the verbatim string literal character (@) to build the string exactly as it appears within the double quotation marks.
string path = @"C:\Programs\MyProgram\My.exe";