title: Loop through all unchecked Checkboxes (foreach or for-loop, Windows Forms)
body: <p>I would like to compress the executable code segment (see below). How to do this with a foreach or for-loop?</p>
  <pre><code>private void UncheckCheckBox() 
  {
     CheckBox[] Three = new [] 
     {
       checkBox1,
       checkBox2,
       checkBox3
     };
  
     checkBox1.Tag = &quot;str1&quot;;
     checkBox2.Tag = &quot;str2&quot;;
     checkBox3.Tag = &quot;str3&quot;;
  
     if (!checkBox1.Checked) 
     {
       listBox4.Items.Remove(checkBox1.Tag);
     }
     if (!checkBox2.Checked) 
     {
       listBox4.Items.Remove(checkBox2.Tag);
     }
     if (!checkBox3.Checked) 
     {
       listBox4.Items.Remove(checkBox3.Tag);
     }
  }
  </code></pre>