Generating a Random Number

Mar 27 2008 2:11 PM

I am trying to generat a random number.

Code:

int pickRandomNumbers()

   {

      Random pickNum = new Random();

      int random1 = pickNum.Next(1, 20);

      return random1;

   }

 

void displayQuestion()

   {

      num1 = pickRandomNumbers();

      num2 = pickRandomNumbers();

      lblQuestion.Text = "How much is " + num1 + " times " + num2 + " ?";

   }

When I run the program, the question displays the same number, BUT when I Debug and follow the code, it gives me different numbers?

I understand that random uses the Time to help pick. Do i need to force it to wait a second, or what?

HELP?


Answers (1)