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[]?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With