I would like to compress the executable code segment (see below). How to do this with a foreach or for-loop?
private void UncheckCheckBox()
{
CheckBox[] Three = new []
{
checkBox1,
checkBox2,
checkBox3
};
checkBox1.Tag = "str1";
checkBox2.Tag = "str2";
checkBox3.Tag = "str3";
if (!checkBox1.Checked)
{
listBox4.Items.Remove(checkBox1.Tag);
}
if (!checkBox2.Checked)
{
listBox4.Items.Remove(checkBox2.Tag);
}
if (!checkBox3.Checked)
{
listBox4.Items.Remove(checkBox3.Tag);
}
}
Aucun commentaire:
Enregistrer un commentaire