Link to home
Start Free TrialLog in
Avatar of chaleastale
chaleastale

asked on

I want my enumeration to contain an entry like "Mail/Telephone Order". I am having an error due to the front slash character.

I have an enumeration and its structure looks like this:

public enum MerchantBusinessTypes
{
      Mail/Telephone Order = 1,
       Internet,
                 QSR/QPS    

}

I am having an error to define entries like 'QSR/QPS' and 'Mail/Telephone Order '. How can I define such entries containig slash characters, spaces and the like?

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PoeticAudio
PoeticAudio

you can't define them with slashes like that because that's a division operator. You might have to adjust your naming convention such as

public enum MerchantBusinessTypes
{
     Mail_or_Telephone_Order = 1,
     Internet,
     QSR_Or_QPS
}

or the like
You can't in an enum, because they have to follow CLR member naming conventions (numbers, characters, and underscores).  Other alternatives would be a dictionary (Hashtable or Dinctionary<>, for example) or to convert all special characters to underscores.  I have done this where the enum values are displayed with spaced replacing the underscores:

public enum BusinessType
{
  Corporation,
  Limited_Liability_Company,
  ...
}

And at display time I convert the underscores to spaces.  You'd have to come up with another token to represent slashes(