How to display the string value of a Enum in C# ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

Below is a sample sourcecode that demonstrates how to display the string value of a Enum in C# ?

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{  
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Designation.TraineeEngineer.ToString());            
            Console.ReadLine();
        }
        enum Designation
        {
            SoftwareEngineer = 1 ,
            TraineeEngineer = 2 ,
            Architect = 10
        }
    }
}
%d bloggers like this: