A very simple random problem-please help
Hi all
I wrote a simple code that should generate two different random numbers.
I designed a window in which I placed two labels and one button.
On the button click event the lebels should show two different numbers between 3-19.
the problem is when I click the button the two labels always show the same number when I use the "F11" to see the step by step happening inside the code the resault come out OK. why isn't it goes that way when I run(F5) the program???
the code goes somthing like that:
private void button1_click(....)
{
dieRoller myRoll = new dieRoller();
label1.text = myRoll.Roller().ToString();
label2.text = myRoll.Roller().ToString();
}
Class dieRoller
{
public int Roller()
{
int randNum;
Random roll = new Random();
randNum = (int)(roll.NextDouble()*16)+3;
return randNum;
}
}
what is wrong here???