title: How would I loop over all the checkboxes in my form?
body: <p>I'm working on an application for school in which you can add games into a list who's information is later displayed on the screen.</p>
  
  <p>In the form, there are 8 checkboxes and each one represents a console. You can check the consoles on which the game is available.</p>
  
  <p>As a result I want to get an array of booleans that contains 8 different values, one for each console.</p>
  
  <p>I believe that my code is not compact and there should be a much better solution. Is there a way that I can loop over the code instead of writing some code for every single checkbox?</p>
  
  <p>This is currently what I have.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e) 
  {
      bool[] platforms = new bool[8] { false, false, false, false, false, false, false, false };
      if (checkBox1.Checked) 
      {
          platforms[0] = true;
      }
      if (checkBox2.Checked) 
      {
          platforms[1] = true;
      }
      if (checkBox3.Checked) 
      {
          platforms[2] = true;
      }
      if (checkBox4.Checked)
      {
          platforms[3] = true;
      }
      if (checkBox5.Checked)
      {
          platforms[4] = true;
      }
      if (checkBox6.Checked)
      {
          platforms[5] = true;
      }
      if (checkBox7.Checked)
      {
          platforms[6] = true;
      }
      if (checkBox8.Checked)
      {
          platforms[7] = true;
      }
  }
  </code></pre>