meng

meng

  • NA
  • 24
  • 19.8k

get random number

Oct 5 2012 7:28 PM
Hi,
I am trying to generate two different random numbers to display two different dice numbers on two image controls.  The btn click event had the following code(below), every time I click the btn click event, both image controls show the same dice number.  Please advise how to display different dice numbers on each image control?
Example, imgDDiceOne.Image will show dice number 5, imgDDiceOne.Image will show dice number 1.
Random rd1 = new Random();
Random rd2 = new Random();

int rol1 = rd1.Next(1, 6);
int rol2 = rd2.Next(1, 6);

imgDDiceOne.Image = Image.FromFile(filepath + "die-" + rol1.ToString() + ".gif");

imgDDiceTwo.Image = Image.FromFile(filepath + "die-" + rol2.ToString() + ".gif");
 

thanks

Answers (5)