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
C#ASP.NET.NET Programming

Avatar of undefined
Last Comment
ksd123
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ksd123
ksd123

ASKER

Thank you
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo