In .NET framework, System.Random class does not offer true random behavior. If you create two instances of System.Random and invoke Next() method on each of the instances, it will return the same value.
Random random = new Random();
Random random2 = new Random();
Console.WriteLine(random.Next());
Console.WriteLine(random2.Next());
Console.WriteLine(random.Next(1, 1000000));
Console.WriteLine(random2.Next(1, 1000000));
Console.WriteLine(random.Next(1, 100000));
Console.WriteLine(random2.Next(1, 100000));
Console.WriteLine(random.Next(1, 10000));
Console.WriteLine(random2.Next(1, 10000));
However if you changed the above code to have a little wait (I used Thread.Sleep) between the steps that create the instances of Random class, then these instances produce different values.
Random random = new Random();
System.Threading.Thread.Sleep(10);
Random random2 = new Random();
Console.WriteLine(random.Next());
Console.WriteLine(random2.Next());
Console.WriteLine(random.Next(1, 1000000));
Console.WriteLine(random2.Next(1, 1000000));
Console.WriteLine(random.Next(1, 100000));
Console.WriteLine(random2.Next(1, 100000));
Console.WriteLine(random.Next(1, 10000));
Console.WriteLine(random2.Next(1, 10000));
It is because Random's constructor uses current time to set up its seed value. This is something you need to keep in mind the next time you are working on creating random values.
Random random = new Random();
Random random2 = new Random();
Console.WriteLine(random.Next());
Console.WriteLine(random2.Next());
Console.WriteLine(random.Next(1, 1000000));
Console.WriteLine(random2.Next(1, 1000000));
Console.WriteLine(random.Next(1, 100000));
Console.WriteLine(random2.Next(1, 100000));
Console.WriteLine(random.Next(1, 10000));
Console.WriteLine(random2.Next(1, 10000));
However if you changed the above code to have a little wait (I used Thread.Sleep) between the steps that create the instances of Random class, then these instances produce different values.
Random random = new Random();
System.Threading.Thread.Sleep(10);
Random random2 = new Random();
Console.WriteLine(random.Next());
Console.WriteLine(random2.Next());
Console.WriteLine(random.Next(1, 1000000));
Console.WriteLine(random2.Next(1, 1000000));
Console.WriteLine(random.Next(1, 100000));
Console.WriteLine(random2.Next(1, 100000));
Console.WriteLine(random.Next(1, 10000));
Console.WriteLine(random2.Next(1, 10000));
It is because Random's constructor uses current time to set up its seed value. This is something you need to keep in mind the next time you are working on creating random values.