关于c#中全局变量的问题,请大家帮忙.
同一个文件下面:
protected void Button1_Click(object sender, EventArgs e)
{
SortedList s = new SortedList();
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
请问在此处如何调用实例s呢,我试着在初始化s的时候加上pulbic但是在vs2005中提示错误,
请问应当如何实现?
}
------解决方案--------------------SortedList s;
protected void Button1_Click(object sender, EventArgs e)
{
s = new SortedList();
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
s.方法();
}
------解决方案--------------------private SortedList s ;
写在类声明中.