mercredi 19 décembre 2018

Getting the value of an integer array from LIST<>

Can anyone tell me why the message box is not displaying the value of the random number? I'm trying to get 10 random numbers and display them one at a time in a message box. The numbers can repeat, and should be between 1 and 4.

public void GetRandomPattern()
        {
            List<int> pattern = new List<int>();

            rounds = 10;
            Random number = new Random();

            for (int counter = 0; counter < rounds; counter++)
            {
                pattern.Add(number.Next(1, 4));
                MessageBox.Show(pattern.ToString());
            }
        }




Aucun commentaire:

Enregistrer un commentaire