你的代码可以优化为:string rblKey="";
//遍历页面所有控件foreach(Control ctrl in Page.Controls)
{
if (ctrl is RadioButtonList) //判断是否是RadioButtonList控件
{
int iSelIdx=(ctrl as RadioButtonList).SelectedIndex;
if(iSelIdx>=0&&iSelIdx<4)
rblKey=((char)(iSelIdx+'A')).ToString();
}
ArrayList arrKey=new ArrayList();
arrKey.Add(rblKey);
}不过,你的代码中还有其它的问题(不能说是错误)。
//遍历页面所有控件foreach(Control ctrl in Page.Controls)
{
if (ctrl is RadioButtonList) //判断是否是RadioButtonList控件
{
int iSelIdx=(ctrl as RadioButtonList).SelectedIndex;
if(iSelIdx>=0&&iSelIdx<4)
rblKey=((char)(iSelIdx+'A')).ToString();
}
ArrayList arrKey=new ArrayList();
arrKey.Add(rblKey);
}不过,你的代码中还有其它的问题(不能说是错误)。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货