Amit Ziv

Amit Ziv

  • NA
  • 40
  • 8.7k

How to avoid random numbers duplication?

Apr 19 2014 11:23 AM
ive created 2 seperate randoms:


 private Random r1 = new Random();
        private Random r2 = new Random();

then i did the random.next method:

maxGreenDelay = r1.Next(10, 40);
            maxRedDelay = r2.Next(10, 40);

and the same numbers appeared.
how can i avoid that? (get 2 different randoms withing this min - max values)


Answers (4)