Is it possible to create an enum whose object can't be created but can be used for readonly purpose

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-05-12T09:02:25Z Indexed on 2010/05/12 9:04 UTC
Read the original article Hit count: 218

Filed under:
|
|
|
|

I created an enum where I stored some table names. I want it to be used to get the name of the table like ds.Tables[BGuestInfo.TableName.L_GUEST_TYPE.ToString()].

  public enum TableName : byte
        {
            L_GUEST_TYPE = 0
            ,L_AGE_GROUP = 1
            ,M_COMPANY = 2
            ,L_COUNTRY = 3
            ,L_EYE_COLOR = 4
            ,L_GENDER = 5
            ,L_HAIR_COLOR = 6
            ,L_STATE_PROVINCE = 7
            ,L_STATUS = 8
            ,L_TITLE = 9
            ,M_TOWER = 10
            ,L_CITY = 11
            ,L_REGISTER_TYPE = 12
        }

This is my enum. Now I have not created any object of this enum so that no one can use it for other than read only purpose.

For this enum to be accessible in outer classes as well I have to make it public which means some outer class can create its object as well.

So what can i do so as to restrict its object creation.

© Stack Overflow or respective owner

Related posts about enums

Related posts about c#