You seem to check the same radio button in most of the cases. Should the code look like:
public String whatChecked()
{
if (a1.Checked)
{
return "a1";
}
else if (a2.Checked)
{
return "a2";
}
else if (a3.Checked)
{
return "a3";
}
else if (a4.Checked)
{
return "a4";
}
else if (a5.Checked)
{
return "a5";
}
else if (a6.Checked)
{
return "a6";
}
else
{
return null;
}
}
ADDED:
private void radioButtons_CheckedChanged(Object sender, EventArgs e)
{
if (a1.Checked))
{
}
}
And in the Form_Load event or constructor, wire all the check boxes to use the same event handler
this.a1.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
this.a2.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
this.a3.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
this.a4.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
...