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[]
?
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.