I have a panel with 5 checkboxes in it, one for each weekday. The user in this scenario is booking appointments on the week. I have a WeeklyBooking class. This class has five bools, Monday, Tuesday, Wednesday, Thursday, Friday. By default, all bools are set to false. When a checkbox is checked, the corresponding bool becomes true.
private void CheckCBs(WeeklyBooking week)
{
if (MondayCB.Checked)
{
week.monday = true;
}
if (TuesdayCB.Checked)
{
week.tuesday = true;
}
if (WednesdayCB.Checked)
{
week.wednesday = true;
}
if (ThursdayCB.Checked)
{
week.thursday = true;
}
if (FridayCB.Checked)
{
week.friday = true;
}
return;
}
This is a method I call in a different method while I build the object to be put in an SQL Table. Does Anybody have any advice for how to optimise this method? - Thanks.
Aucun commentaire:
Enregistrer un commentaire