How can I make a random color generator, but only using 5 colours that I choose for my program. Im doing a priority system that uses colors to attribute to each pacient at an hospital.
Thanks in advance.
How can I make a random color generator, but only using 5 colours that I choose for my program. Im doing a priority system that uses colors to attribute to each pacient at an hospital.
Thanks in advance.
Try this simple example:
static Color[] colors = { Color.Red, Color.Green... };
static Color GetRandomColor()
{
var random = new Random();
return colors[random.Next(colors.Length)];
}
And don't forget using System.Drawing
.
Here you go
// Define your colors array
string[] colors = { '#4FC1E9' , '#FE424D', '#1AA6B7', '#967ADC', '#48cfad' };
// Get a random index
Random rnd = new Random();
int r = rnd.Next(colors.Length);
string randomColor = ((string)colors[r]);