Solved

best way to use enums

Posted on 2012-03-23
4
301 Views
Last Modified: 2012-03-23
Hi,

I want to have re-usuable enums throughout my application.

Is the best way to have a static class containing the enums that I can then just use without creating a new instance of the class?
0
Comment
Question by:scm0sml
  • 2
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 450 total points
ID: 37758112
You don't need a static class, just define them outside of any class, but within the namespace block.

Example:

namespace My.Application.Example
{

    public enum ApplicationType
    {
        CSharp,
        FSharp,
        RSharp,
        PHP,
        VisualBasic,
    }
  
    public class Example
    {
    }

}

Open in new window

0
 
LVL 7

Assisted Solution

by:Bill Nolan
Bill Nolan earned 50 total points
ID: 37758415
It completely depends on the scope you feel is appropriate.  Sometimes an enum should belong to a class (esp. a static class), sometimes to a namespace.  Etc.
0
 

Author Closing Comment

by:scm0sml
ID: 37758452
as per the question i was looking for it to be available across my project
0
 
LVL 7

Expert Comment

by:Bill Nolan
ID: 37758517
Yes, but the static class could also be available across your project.  It's just a matter of where it "belongs".
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 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