10

Possible Duplicate:
What does the @ symbol before a variable name mean in C#?

I have been coding in C# for about a year now, and recently i came across the following

public bool OnPreUpdate(PreUpdateEvent @event)

As you can see event has an '@' sign before it, is this just to prevent the compiler detecting it as the event type, therefore does '@' gets treated as any other text or is there a special meaning to it?

Community
  • 1
  • 1
Michal Ciechan
  • 12,808
  • 11
  • 72
  • 111

3 Answers3

14

An @ sign lets you use C# keywords in identifiers; if you remove the @ then you'll get a syntax error.

Tim Robinson
  • 51,912
  • 9
  • 117
  • 136
2

The @ symbol prevents the name from clashing with a C# reserved word.

Alex McBride
  • 6,771
  • 3
  • 30
  • 30
1

@ is used in front of keywords so that they are treated as ordinary variables or parameters.

Giorgi
  • 29,755
  • 12
  • 86
  • 122