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
  • 94,086
  • 102
  • 195
  • 339
omriman12
  • 1,528
  • 6
  • 24
  • 45

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
  • 69,953
  • 7
  • 104
  • 182