Is there a cleaner way to write this code. I get the feeling there may be, but I don’t know how.
if (loadedFormData.Education.AwardedADegree==true)
{
this.radiobuttonNoAwarded.Checked = false;
this.radiobuttonYesAwarded.Checked = true;
}
if (loadedFormData.Education.AwardedADegree == false)
{
this.radiobuttonNoAwarded.Checked = true;
this.radiobuttonYesAwarded.Checked = false;
}
else // AwardedADegree is null
{
this.radiobuttonNoAwarded.Checked = false;
this.radiobuttonYesAwarded.Checked = false;
}
Ask the question “when should my
radiobuttonbe checked”, instead of “what should happen when my data is true/false/null”.