asp.netC#问题

来源:百度知道 编辑:UC知道 时间:2024/05/17 09:15:24
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
string T ="";
foreach (ListItem item in RadioButtonList1.Items)
{

if (RadioButtonList1.SelectedValue =="0"){T = "饼装图";}
if (RadioButtonList1.SelectedValue =="1"){T = "柱状图";}
if (RadioButtonList1.SelectedValue =="2"){T = "折线图";}

}

}
在这里得到的T的值怎么才能在自己建的C#类的方法里运用到这个T的值呢?
那应该怎么来声明这个T?在哪声明?我是新手。不好意思。多问问。呵呵。

你声明的领域有问题。你在函数体内生命的对象只能在函数体内使用。

如果你要在类内使用,应该在一开始就应该声明这个T

如果不被类外调用。可以设置成保护类型也就是protected如果需要被类外访问那就设置成public就行了。
-------------------------------------------

在Class内 也就是和函数同级