mercredi 20 décembre 2017

C# Array Random Size

Im currently trying to create and display an array in list box

the array must be random size between 10-50 and random element. im really new to programming so forgive me. So here's my code.

 private void btnStart_Click(object sender, EventArgs e)
    {

        Random r = new Random();
        int minArraySize = 10;
        int maxArraySize = 51;
        int[,] newArray = new int[minArraySize, maxArraySize];
        int arraySize = newArray.Length;
        int[] initialArray = new int[arraySize];
        int num = r.Next();
        lstArray.Text = num.ToString();
        for (int i = 0; i <= num; i++)
        {
            num = r.Next();
            lstArray.Text = lstArray.Text + num.ToString();
        }




Aucun commentaire:

Enregistrer un commentaire