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
  • 13,492
  • 11
  • 76
  • 118

3 Answers3

15

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

Tim Robinson
  • 53,480
  • 10
  • 121
  • 138
2

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

Alex McBride
  • 6,881
  • 3
  • 29
  • 30
1

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

Giorgi
  • 30,270
  • 13
  • 89
  • 125