jeudi 25 mai 2017

Random class C# printing values the same each time application runs

I would like to get random values using Random class the same each time application runs and only different when I change seed value or initialize random class.

I declare Random random = new Random(); as a global parameter.

Then I print 3 random doubles:

for (int i = 0; i < 3; i++) 
 Console.WriteLine(random.NextDouble())

Each time application runs I get different values

For instance first time I run application I get values 0.454, 0.256, 0.100

Second time 0.578, 0.123, 0.001

But what I would to have is that each time application runs I would get the same numbers

For example first time I run app I get 0.454, 0.256, 0.100 Second time 0.454, 0.256, 0.100




Aucun commentaire:

Enregistrer un commentaire