mardi 30 mai 2017

C# return a random number twice in while loop [duplicate]

This question already has an answer here:

Hey im trying to return a random number from a method. my code works, it returns a random number, but the problem is that its the same number it returns if i use it twice in the same while loop, how do i fix the problem? if there is a fix to the problem.

My code look like this

 private int ReturnARandomNumber(int min, int max)
 {
    var randomNumber = new Random();
    return randomNumber.Next(min, max);
 }

- Morten syhler




Aucun commentaire:

Enregistrer un commentaire