Possible Duplicate:
C# Enums – can my enums have friendly names?
Cast string to enum with enum attribute
I have enum with byte values:
enum MarketingEventType : byte {MARKETING_CAMPAIGN, TELESALES, MARKETING_ACTIONS};
I would like to give for all element name, which I will get by ToSting() method.
For example:
MarketingEventType.TELESALES.ToString(); // I get "bla bla bla"
MarketingEventType.MARKETING_ACTIONS.ToString(); // I get "la la la"
It is possibe without change type of enum from BYTE to STRING?
You can’t set an enum type to
string. Valid base types arebyte,sbyte,short,ushort,int,uint,long, andulong.You can, however, use the
Descriptionattribute:Retrieving the enum description is kind of a mess, but you can use this method (or even make an extension method out of it!):