Posted By

dimitrisdapontes on 01/26/13


enum description

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Enum Description

 / Published in: C#

Returns the description set in an enum value, or if not description is found it returns the name of the enum value. Use this without worrying about passing the enum type, you should only pass the enum value


internal enum Duration
    [Description("Every 12 Months")] Year = 1
    [Description("Every 6 Months")] Semester = 2

GetEnumDescription(Duration.Year) returns "Every 12 Months"

Report this snippet  

You need to login to post a comment.