What is the @ Sign in front of parameters [duplicate]
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 ev开发者_JAVA技巧ent 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?
An @
sign lets you use C# keywords in identifiers; if you remove the @
then you'll get a syntax error.
The @ symbol prevents the name from clashing with a C# reserved word.
@ is used in front of keywords so that they are treated as ordinary variables or parameters.
精彩评论