C#中变量名前的@符号是什么意思?

C#中变量名前的@符号是什么意思?

问题描述:

可能的重复:
@的用途/含义是什么C#中变量名中的字符?

我知道可以在字符串文字之前使用@ 符号来更改编译器解析字符串的方式.但是当变量名以@ 符号为前缀时,这意味着什么?

I understand that the @ symbol can be used before a string literal to change how the compiler parses the string. But what does it mean when a variable name is prefixed with the @ symbol?

@ 符号允许您使用保留字.例如:

The @ symbol allows you to use reserved word. For example:

int @class = 15;

以上有效,而以下无效:

The above works, when the below wouldn't:

int class = 15;