代码如下,在最后if (strarm == tmp)判定时编译器老是提醒我tmp的值为空,不能比较,这是为什么呢?
string tmp;
RadioButton A = (RadioButton)DataList1.Items[i].FindControl("RA");
RadioButton B = (RadioButton)DataList1.Items[i].FindControl("RB");
RadioButton C = (RadioButton)DataList1.Items[i].FindControl("RC");
RadioButton D = (RadioButton)DataList1.Items[i].FindControl("RD");
Label showre = ((Label)DataList1.Items[i].FindControl("Label4"));
string strarm = ((Label)DataList1.Items[i].FindControl("Label3")).Text.Trim();
if (A.Checked)
{
tmp = "A";
}
else if (B.Checked)
{
tmp = "B";
}
else if (C.Checked)
{
tmp = "C";
}
else if (D.Checked)
{
tmp = "D";
}
if (strarm == tmp)//问题所在,提示tmp是null
{
score = score + 1;
}