I have a class project. I need to fill a form with multicolored snow using an array. I've loaded 3 colors into an array, but I can't get it to randomly pick from the array because it can't convert system.drawing.color to an integer. Can anyone help me get around this? This is my code so far.
insert
Code:
System.Drawing.Color[] colorList = new System.Drawing.Color[3];
colorList[0] = Color.Orange;
colorList[1] = Color.Green;
colorList[2] = Color.Red;
DateTime currentDateTime = DateTime.Now;
Random colorRandom = new Random(currentDateTime.Millisecond);
Color snowPen;
snowPen = colorList[];
DateTime currentDateTime2 = DateTime.Now;
Random snowRandom = new Random(currentDateTime.Millisecond);
int xIntegerSnow = Convert.ToInt32(this.Width / 2),
yIntegerSnow = Convert.ToInt32(this.Height / 2);
Pen whitePen = new Pen(snowPen, 2);
// Make it snow in random locations.
for (int indexInteger = 1; indexInteger < 40000; indexInteger++)
{
int xInteger = snowRandom.Next(1, this.Width);
int yInteger = snowRandom.Next(1, this.Height);
e.Graphics.DrawLine(whitePen, xInteger, yInteger,
xInteger + 1, yInteger + 1);
}
}