ブール値のリストをパラメーターとして受け取り、リストを個別に検証して各checkListのチェック状態を設定する次のコードがあります。
次のコードをもっと効率的に書く方法はありますか? たとえば、ループを使用して?
public PointCtrlRowSelectionForm(List<Boolean> checkList, PointCtrlForm form, string title)
{
InitializeComponent();
this.form = form;
this.Text = title;
if (checkList[0] == true)
{
checkBox1.Checked = true;
checkBox1.CheckState = CheckState.Checked;
}
if (checkList[1] == true)
{
checkBox2.Checked = true;
checkBox3.CheckState = CheckState.Checked;
}
if (checkList[2] == true)
{
checkBox3.Checked = true;
checkBox3.CheckState = CheckState.Checked;
}
if (checkList[3] == true)
{
checkBox4.Checked = true;
checkBox4.CheckState = CheckState.Checked;
}
if (checkList[4] == true)
{
checkBox5.Checked = true;
checkBox5.CheckState = CheckState.Checked;
}
if (checkList[5] == true)
{
checkBox6.Checked = true;
checkBox6.CheckState = CheckState.Checked;
}
}