4
Answers

How to avoid random numbers duplication?

Amit Ziv

Amit Ziv

10y
953
1
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)