1

I have declared an enum as follows:

public enum Numbers    {
    One= 1,
    Two
}

Now, I need to return the key and value pair of the Enum as an array shown below. How can I do this ?

Expected Output

[{ "1": "One" }, { "2": "Two" } ]

What I was trying

This gives the values, but not the key and I need to structure it in to an array.

var values = Enum.GetValues(typeof(Numbers));

Illep
  • 16,375
  • 46
  • 171
  • 302
  • Note the comment [here](https://stackoverflow.com/questions/5583717/enum-to-dictionary-in-c-sharp#comment60307589_5583817) in the linked answer. You may want to group and take the first entry for a given value. – ProgrammingLlama Jul 26 '21 at 07:01

0 Answers0