public static string RadioList(System.Web.UI.WebControls.RadioButtonList RadioList)
{
for (int x = 0; x <= RadioList.Items.Count - 1; x++)
{
if (RadioList.Items[x].Selected)
{
string RadioBody= RadioList.Items[x].Value;
return RadioBody;
}
}
}
提示:并非所有代码路径都有返回值
{
for (int x = 0; x <= RadioList.Items.Count - 1; x++)
{
if (RadioList.Items[x].Selected)
{
string RadioBody= RadioList.Items[x].Value;
return RadioBody;
}
}
}
提示:并非所有代码路径都有返回值
{
string RadioBody = "";
for (int x = 0; x <= RadioList.Items.Count - 1; x++)
{
if (RadioList.Items[x].Selected)
{
RadioBody= RadioList.Items[x].Value; }
}
return RadioBody;}
{
string RadioBody = "";
for (int x = 0; x <= RadioList.Items.Count - 1; x++)
{
if (RadioList.Items[x].Selected)
{
RadioBody= RadioList.Items[x].Value;
break;
}
}
return RadioBody;
}
这个所以你最后有个默认的返回值
这个提示的原因是,如果一个方法有返回值的情况下,编译程序会检验不管程序如何执行都要有返回值的。以你的程序为例,如果if执行后为FALSE。则return将不执行,所以你的方法就没有返回值。编译是不会通过的。