try in this way
private static Random rand = new Random();
color= Color.FromArgb(this.rand.Next(256), this.rand.Next(256), this.rand.Next(256));
refer here for documentation about Color.FromArgb
you can create the color in 3 differents overloads with this function (using only int32)
-
one integer –> Creates a Color structure from a 32-bit ARGB value.
-
three integers –> Creates a Color structure from the specified 8-bit color values (red, green, and blue). The alpha value is implicitly 255 (fully opaque). Although this method allows a 32-bit value to be passed for each color component, the value of each component is limited to 8 bits.
- four integers–> Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values. Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits.
solved How do I find a random color in C# [closed]