What is the purpose of @ as part of a member name in C #?

Possible duplicates:
What does placing @ in front of a C # variable name do? What does the use / value of the @ symbol mean in variable names in C #?

As you can imagine, Googling or Binging for any phrase containing "@" is difficult.

When creating a new web service, one of the members of the imported C # proxy class has the @ prefix. For example:

plan.@event = new Insurance.Event(); 

I assume this is a Visual Studio method that resolves potential conflicts with reserved words, because "event" is a reserved word. Changing a property in the web service interface to something other than an "event" (ie, "Healthevent") removes @ from the property. Is this the correct assumption?

+7
c # web-services
source share
3 answers

You're right. See C # Keywords , section 2.4.2 Identifiers, language specification or string (C # link) .

In the keywords section:

Keywords are predefined, identifiers that have special meaning to the compiler are reserved. They cannot be used as identifiers in your program if they include @ as a prefix. For example, @if is a valid identifier, but if is not, because if is a keyword.

+2
source share

Yes, names that conflict with C # keywords can be escaped with the @ symbol.

+8
source share

Yes, that's right. You can use keywords as identifiers if you include @ as a prefix.

See http://msdn.microsoft.com/en-us/library/x53a06bb.aspx for more details.

+5
source share

All Articles