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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(
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(
public enum MerchantBusinessTypes
{
Mail_or_Telephone_Order = 1,
Internet,
QSR_Or_QPS
}
or the like