c#中@的三种用法:

1.忽略转义字符 \

string str = "C:\\windows\\system32";

string str = @"C:\windows\system32";

2.字符串跨行

string str = "line one"

  + "line two"

  + "line three"

  + "line fore";

string str = @"line one

  line two

  line three

  line fore";

3.将关键字作为标识符使用
C#是不允许关键字作为标识符(类名、变量名、方法名、表空间名等)使用的,但如果加上@之后就可以了

int @int = 1;

$的作用

简化string.Format()写法,行驶Format的作用

string name = "KaiSarH";

int age = 0;

string str_1 = string.Format("my name is {0},I`m {1} years old",name,age);

可简写为

string str_1 = $"my name is {name},I`m {age} years old";

Else

如果在字符串中想要输出引号,不管是"还是’,都需要在其前面加一个转义字符\

如果在字符串中像输出{},需要使用{{}}