What's the use/meaning of the @ character in variable names in C#?

后端 未结 9 900
小蘑菇
小蘑菇 2020-11-22 01:25

I discovered that you can start your variable name with a \'@\' character in C#. In my C# project I was using a web service (I added a web reference to my project) that was

9条回答
  •  盖世英雄少女心
    2020-11-22 02:02

    Straight from the C# Language Specification, Identifiers (C#) :

    The prefix "@" enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier.

提交回复
热议问题