Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
238 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 375 total points
ID: 17110648
You can't.

Try using Mail_Telephone_Order or MailTelephoneOrder.

Bob
0
 
LVL 6

Expert Comment

by:PoeticAudio
ID: 17110658
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
ID: 17110707
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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

885 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