5
Answers

get random number

meng

meng

12y
3.4k
1
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)
0
c_wiley
NA 57 0 21y
I think decimal.Round(Expre, Decimal places) should do it for you? decimal.Round(lcVar,2) Craig
0
madinewala
NA 164 0 21y
you could better look into System.Decimal namespace within the .NET documentation.