I'm trying to fill a checkbox array with checkbox names derived from strings. I would like to replace the following code:
public void CheckBox_1()
{
CheckBox[] boxes_1 = new CheckBox[4];
boxes_1[0] = A0;
boxes_1[1] = A1;
boxes_1[2] = A2;
boxes_1[3] = A3;
for (int i = 0;i < 4;i++)
{
boxes_1[i].Enabled = checkBox1.Checked == true ? true : false;
}
}
with something like this:
public void CheckBox_1()
{
CheckBox[] boxes_1 = new CheckBox[4];
for (int i = 0; i < 4; i++)
{
boxes_1[i] = ("A" + i);
}
for (int i = 0; i < 4; i++)
{
boxes_1[i].Enabled = checkBox1.Checked == true ? true : false;
}
}
I can get the checkbox name to a string easy enough, but it's not clear how to accomplish this. Thanks.