- 加在关键字前,可以当作正常的标识符使用,如:
@class
- 加在字符串前,表示原样输出字符串:
string j = @"one
two
three";
System.Console.WriteLine(j);
输出的结果为:
one
two
three
特别值得注意的是,@对字符串的双引号具有识别和解析功能,因为它需要知道到哪里结束。两个双引号连在一起,会输出一个双引号,当两个双引号分开时,会报错。
static void Main(string[] args)
{
string str = @"Hello ""Kitty"" World!";
System.Console.WriteLine(str);
}
Hello “Kitty” World!