开发者

What is the @ Sign in front of parameters [duplicate]

This question already has answers here: Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜