How do I put special characters in enum?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wanted to create an enum with the following:
SSN,
EIN,
N/A
But it doesn't like the /. How can I put / or ? characters into the list.
Also is it possible to have blanks as a valid enum? or Null?
 
I believe that an enum only allows alphanumeric characters as the identifier
and the value has to have an underlying type of integral, so you will not be
able to do N/A. you could put NotAvailable which is still clear what it
means in the enum.
 
1) To many people try to fight the compiler. Is there some reason that you
could not use the enum value "NA" rather then "N/A". We are after all just
talking about symbols that only the code sees. These values are normally
not displayed to the user.
2) What do you mean "blanks"? Do you mean spaces or an enum value that has
no value? I would imagine that this is not possible. Enums are meant to be
basically constants.
3) Enums are only numeric value types, they cannot be "null".

If you need the enum to support these concepts, then you might want to
reevaluate your design.
 
But it doesn't like the /. How can I put / or ? characters into the list.
Also is it possible to have blanks as a valid enum? or Null?

They have to be valid identifiers, so you are restricted by the same rules
as variable names (the quick summary is: letters, digits, underscore but
cannot start with a digit).
 
Enum members act like variables, and as such must adhere to the same
naming conventions as normal variables.

Best Regards
Johann Blake
 
Back
Top