2

I want to get all Enum.values as string[].

I tryed using

Array mPriorityVals = Enum.GetValues(typeof(MPriority));

But how do I cast it as string[]?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
omriman12
  • 1,644
  • 7
  • 25
  • 48

1 Answers1

14

You just need Enum.GetNames method, Enum.GetValues gives the result as EnumType rather than string.

string[] names = Enum.GetNames(typeof (MPriority));

I suggest you to just use GetNames, don't call GetValues and cast it to string as suggested in comment.

Sriram Sakthivel
  • 72,067
  • 7
  • 111
  • 189