How to generate random color names in C#

Use Enum.GetValue to retrieve the values of the KnownColor enumeration and get a random value:

Random randomGen = new Random();
KnownColor[] names = (KnownColor[]) Enum.GetValues(typeof(KnownColor));
KnownColor randomColorName = names[randomGen.Next(names.Length)];
Color randomColor = Color.FromKnownColor(randomColorName);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)