-4
enum EmpName
{ 
    FirstName = 1, 
    LastName = 2
};

How do I get the following result:

  1. FirstName
  2. LastName
Lews Therin
  • 3,707
  • 2
  • 27
  • 53
Kumar
  • 1
  • You definetely need [Enum.GetNames()](https://msdn.microsoft.com/en-us/library/system.enum.getnames(v=vs.110).aspx) method – Fabjan May 31 '16 at 12:24
  • 4
    Possible duplicate of [Enum String Name from Value](http://stackoverflow.com/questions/309333/enum-string-name-from-value) – Matt Rowland May 31 '16 at 12:25

1 Answers1

0

Try this:

foreach (var name in Enum.GetNames(typeof(EmpName)))
{
    Console.WriteLine(name);
}

Output will be:

FirstName
LastName

Nasreddine
  • 36,610
  • 17
  • 75
  • 94