Verbatim string literal does not require the use of escape characters to define special characters. Instead, any information in the source code, including new lines, is included in the string. To define a string literal an @ symbol is placed before the opening quotation mark. Verbatim string literals are often used for specifying paths and multi-line strings:

    string path = @"C:"Program Files"My Program";        //verbatim literal

    string path2 = "C:""Program Files""My Program";      //regular literal

    string msg = @"Hello,

            This is a multi-line string";                //verbatim literal

    string msg2 = "Hello,"nThis is multi-line string";   //regular literal

P.S. the only character that requires a different action is the quotation mark itself, which must be entered twice to indicate a single character.

posted on 2008-01-15 15:34  josephshi  阅读(269)  评论(0编辑  收藏  举报