Created On:  8 June 2010

Problem:

Question on use of C# string specifier @:

In the C# code snippet below:

            DirectoryInfo info = new DirectoryInfo(@"C:\\Documents and Settings");

The @ specifier indicates a verbatim string in C#.

Resolution:

Here is the definition from the C# programming guide:

Use verbatim strings for convenience and better readability when the string text contains backslash characters, for example in file paths. Because verbatim strings preserve new line characters as part of the string text, they can be used to initialize multiline strings. Use double quotation marks to embed a quotation mark inside a verbatim string. The following example shows some common uses for verbatim strings:

C#  Copy Code
         string filePath = @"C:\\Users\\scoleridge\\Documents\\";
         //Output: C:\\Users\\scoleridge\\Documents\\

         string quote = @"Her name was ""Sara.""";
         //Output: Her name was "Sara."

Since this type of string is the default type in a COBOL literal there is no conversion involved.

COBOL Copy Code:
         01 filePath string value "C:\\Users\\scoleridge\\Documents\\".
         *>Output: C:\\Users\\scoleridge\\Documents\\

         01 wsquote string value "Her name was ""Sara.""".
         *>Output: Her name was "Sara."
     

Incident #2433612