I need to generate random color names e.g. \"Red\", \"White\" etc. How can I do it? I am able to generate random color like this:
Random randonGen = new Ran
Copied code from Retrieve a list of colors in C#
CODE:
private List GetColors()
{
//create a generic list of strings
List colors = new List();
//get the color names from the Known color enum
string[] colorNames = Enum.GetNames(typeof(KnownColor));
//iterate thru each string in the colorNames array
foreach (string colorName in colorNames)
{
//cast the colorName into a KnownColor
KnownColor knownColor = (KnownColor)Enum.Parse(typeof(KnownColor), colorName);
//check if the knownColor variable is a System color
if (knownColor > KnownColor.Transparent)
{
//add it to our list
colors.Add(colorName);
}
}
//return the color list
return colors;
}