Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

best way to use enums

Posted on 2012-03-23
4
Medium Priority
?
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1800 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 200 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

636 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