I met a method in C#
int Func(Contact @group)
{
group.Name = "";
}
What dose the '@' mean ?
It's used to escape keywords so you can have parameters named @class
or similar, which would otherwise result in a syntax error.
See the relevant portion of the specification: 2.4.2 Identifiers
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. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.
I believe it is a literal variable.
Keywords such as int
, double
, etc. cannot be used as variable names, however, you can get round this with the @
symbol:
var int = 3; //compile error
var @int = 3; //okay
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With