识别使用@和不使用它有什么区别
What is the difference between identifying using @ and without it
我是 C# 编程的新手,正在阅读面向程序员的 C Sharp 2010,这打断了我。
Identifiers
may also be preceded by the @ character. This indicates that a word should be interpreted
as an identifier, even if it’s a keyword (e.g., @int). This allows C# code to use code written
in other .NET languages where an identifier might have the same name as a C# keyword.
1 - 谁能举例说明如果使用 @character 中断器会做什么,以及它与不使用 @character 进行识别有何不同。
2- 如何在其他 .NET 语言中使用它
@
字符允许您使用保留关键字作为标识符名称:
int @int = 1;
或
void M(object[] @params)
{ }
没有它,编译器会发出一个错误 (CS1041),指出您正试图将关键字用作标识符名称:
Identifier expected, 'keyword' is a keyword.
A reserved word for the C# language was found where an identifier was expected. Replace the keyword with a user-specified identifier.
可找到保留关键字列表 here。
我是 C# 编程的新手,正在阅读面向程序员的 C Sharp 2010,这打断了我。
Identifiers may also be preceded by the @ character. This indicates that a word should be interpreted as an identifier, even if it’s a keyword (e.g., @int). This allows C# code to use code written in other .NET languages where an identifier might have the same name as a C# keyword.
1 - 谁能举例说明如果使用 @character 中断器会做什么,以及它与不使用 @character 进行识别有何不同。
2- 如何在其他 .NET 语言中使用它
@
字符允许您使用保留关键字作为标识符名称:
int @int = 1;
或
void M(object[] @params)
{ }
没有它,编译器会发出一个错误 (CS1041),指出您正试图将关键字用作标识符名称:
Identifier expected, 'keyword' is a keyword. A reserved word for the C# language was found where an identifier was expected. Replace the keyword with a user-specified identifier.
可找到保留关键字列表 here。