I have an enum type like this:
public enum Colors
{
Black,
Brown,
Red,
Orange,
Yellow,
Green,
Blue,
Violet,
Grey,
White
}
And I want to create an array of strings based on items in this enum type. Like this:
strint[] mylist = {"Black", "Brown", "Red", ... }
Could anyone help me? Thanks.
It's pretty easy, since the Enum class provides a method for that:
string[] mylist = Enum.GetNames(typeof(Colors));
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