5

I met a method in C#

int Func(Contact @group)
{
    group.Name = "";
}

What dose the '@' mean ?

ProBlc
  • 111
  • 9

2 Answers2

7

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.

p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
3

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
dav_i
  • 27,509
  • 17
  • 104
  • 136