Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Making a bingo game in c# visual studio, windows forms. I made a random populate

ID: 3592754 • Letter: M

Question

Making a bingo game in c# visual studio, windows forms. I made a random populated array, without duplicates, for called numbers. I need to print the next element in the array when the "next" button is clicked that prints after the previously called printed numbers (so 14 additional clicks after the initial click). I see why it is printing all elements at once, but I cannot figure out how make it not do that. Show me code that prints one element at a time and adds it to the previous elements printed? Unsure how to make a call that works when I click the "Next" button or if I need a separate function to increment the array and only print the single array element (added to the list of previously printed) when the next button is clicked. I've only had a few weeks learning c# with little other experience. As the code is now, when I click the next button it doesn't increment beyond called[1], I think b/c each "next" button click is reseting the i variable. Please and thanks! The code I have so far is below:

private void btnNext_Click(object sender, EventArgs e)
        {           
//array "called" is global


            lblNumCalled.BackColor = Color.Yellow;
  

            int i = 1;     
            if (called == null)
            {
               
                Random rand = new Random();
                int randNumber = rand.Next(1, 16);
                called = Enumerable
                .Range(1, 15)              // number 1 - 15
                .OrderBy(x => rand.Next()) // randomly shuffled
                .Take(15)                   // we only need 15
                .ToArray();                // as an array please.
                lblNumCalled.Text = Convert.ToString(called[0]);
                lblListOfCalled.Text = Convert.ToString(called[0]);
  
            }

else
            {
                for (i = 1; i < called.Length; i++)
                {
                   
                    lblNumCalled.Text = Convert.ToString(called[i]);
                    lblListOfCalled.Text += " " + called[i];
                   
                }
               
            }           
   }

Explanation / Answer

lblNumCalled.BackColor = Color.Yellow;
  

            int i = 1;     
            if (called == null)
            {
               
                Random rand = new Random();
                int randNumber = rand.Next(1, 16);
                called = Enumerable
                .Range(1, 15)              // number 1 - 15
                .OrderBy(x => rand.Next()) // randomly shuffled
                .Take(15)                   // we only need 15
                .ToArray();                // as an array please.
                lblNumCalled.Text = Convert.ToString(called[0]);
                lblListOfCalled.Text = Convert.ToString(called[0]);
  
            }

else
            {
                for (i = 1; i < called.Length; i++)
                {
                   
                    lblNumCalled.Text = Convert.ToString(called[i]);
                    lblListOfCalled.Text += " " + called[i];
                   
                }
               
            }           
   }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote