Random.Next returns always the same values [duplicate]

The problem is that you are creating instances of the Random class too close in time.

When you create a Random object, it’s seeded with a value from the system clock. If you create Random instances too close in time, they will all be seeded with the same random sequence.

Create a single Random object and pass its reference to the constructor when you create instances of the “a” class, instead of creating one Random object for each “a” instance.

Leave a Comment