39

I'm opening old C# code from my work using Reflector and I found out that there was an enum in an SQL class which looked like this:

public enum Column
{
     bool,
     ...
}

The enum is populated with column types and it doesn't compile due it being a reserved keyword. Obviously someone was able to compile it at some point. How do I get it to compile?

Thanks!

1
  • 23
    Did you try @bool?
    – mellamokb
    Commented May 21, 2012 at 16:21

1 Answer 1

89

You need to prefix with a character literal (@ symbol) in order to use keywords.

MSDN (Thanks @erikH)

6
  • @erikH I wouldn't say better as the other link describes character literals, but I'd say useful. Updated to add your link also :) thanks. Commented May 21, 2012 at 16:43
  • Your link didn't say anything about @. From my point of view it didn't relate to the question. But the first section in my contributed link does. That's why it is better, not cause it contains all reserved keywords.
    – erikH
    Commented May 21, 2012 at 19:02
  • 1
    Actually upon further investigation, it seems your right :). I took mine out and put yours, thanks again. Commented May 21, 2012 at 21:17
  • 6
    in vb you need to place the reserved word inside brackets like this [integer]. just saying.
    – Sharky
    Commented Nov 14, 2016 at 12:59
  • @sharky - props to the inclusive vb crowd ;)
    – stigzler
    Commented Jun 15, 2021 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.