Solved

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

Posted on 2006-07-14
3
225 Views
Last Modified: 2010-04-16
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.
0
Comment
Question by:chaleastale
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
Comment Utility
You can't.

Try using Mail_Telephone_Order or MailTelephoneOrder.

Bob
0
 
LVL 6

Expert Comment

by:PoeticAudio
Comment Utility
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
0
 
LVL 25

Expert Comment

by:dstanley9
Comment Utility
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(
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now