dimanche 24 septembre 2017

Generating "random" number after creating the Random instance [duplicate]

This question already has an answer here:

In my project, players can perform an action and this action requires a random number to count the chance.

I use the following code:

 int random =new Random().Next(3, data.Length);

but of course, this yields the same results (I guess because it is everytime created and queried, the result are always 1 or 2.

Is there a way to create Random instance and let it produce truly random (different than in previous runs) number?




Aucun commentaire:

Enregistrer un commentaire