vendredi 20 janvier 2017

Random number consecutive c# [duplicate]

This question already has an answer here:

Hello Im trying to generate many consecutive random number with a for but i always get the same number. The problem is that I need the for. This is my methode.

public static int roll(int numberRoll, int maxNumber)
    {
        Random random1 = new Random();
        int someRoll = 0;

            for (int i = 0; i < numberRoll; ++i )
        {
            someRoll += random1.Next(1,maxNumber);
        }
        return someRoll;




Aucun commentaire:

Enregistrer un commentaire