Link to home
Create AccountLog in
Avatar of ksd123
ksd123

asked on

How to get Description value of a Enum in C#

I have following code and would like to know how to get Description  value of a Enum from Program class


public enum Samplecolumns
    {
        [Description("one")]
        col1=1,
        [Description("two")]
        col2=2,
        [Description("three")]
        col3=3
    }


public class Sample
    {
          public Samplecolumns Column { get; set; }
    }


public class Program
    {
        static void Main(string[] args)
        {
                //How to get Description of enum ?
         
        }
    }

Open in new window


Thanks in Advance
Avatar of Rikin Shah
Rikin Shah
Flag of India image

int value = 1;
string description = Enumerations.GetEnumDescription((Samplecolumns)value);
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of ksd123
ksd123

ASKER

Thank you