Solved

best way to use enums

Posted on 2012-03-23
4
297 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
Comment Utility
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:Slimfinger
Slimfinger earned 50 total points
Comment Utility
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
Comment Utility
as per the question i was looking for it to be available across my project
0
 
LVL 7

Expert Comment

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

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

11 Experts available now in Live!

Get 1:1 Help Now