views:

867

answers:

2

Hi,

I would like to use "as" and "is" as members of an enumeration. I know that this is possible in VB.NET to write it like this:

Public Enum Test
      [as] = 1
      [is] = 2
End Enum

How do I write the equivalent statement in C#? This:

  public enum Test
    {
        as = 1,
        is = 2
    }

does not compile.

Thanks in advance.

+16  A: 

Prefixing reserved words in C# is done with @.

public enum Test
{
    @as = 1,
    @is = 2
}
Brad Wilson
+3  A: 

You will need to prefix them with the @ symbol to use them. Here is the msdn page that explains it.

-- Edit --
Sorry, nobody had answered when I saw the question. Since this is a duplicate answer, I can delete it if needed. I had a vote up, but somebody voted it down.

Dale Ragan