mercredi 17 mars 2021

Random number generator returns 0 every time [duplicate]

There are similar questions but I did not really understand any of the answers. I want to make the position of the mine random but every time I only get 0, 0 printed.

static void Main(string[] args)
        {
            Mine mine1 = new Mine(RandomGenerator(), RandomGenerator());
            Console.WriteLine(mine1.PositionX);
            Console.WriteLine(mine1.PositionY);
        }
        static int RandomGenerator() 
        {
            Random myRand = new Random();
            return myRand.Next(0, 6);
        }



Aucun commentaire:

Enregistrer un commentaire