在字符串前面加 @ 会取消字符串中的转移 把 " "中的字符原封不动的取出
string str1 = "today is sunday\n";
string str2 = @"today is sunday\n";
Console.WriteLine("{0}{1}", str1, str2);
Console.ReadKey();
输出结果为:
today is sunday
today is sunday\n
其中str1打印出了换行符 而str2打印出了字符串\n
注意:@后面的""字符串中不能出现双引号(如@" today "is" sunday"),否则会提前结束字符串
@ 最主要用到文件名 @"c:\abc\123.txt" 和"c:\\abc\\123.txt"等效