ArrayList testList = new ArrayList();
private void button2_Click(object sender, EventArgs e)
{
ArrayList testList = new ArrayList();//
testList.Add("1");
testList.Add("2");
testList.Add("3");
MessageBox.Show(testList.Count.ToString());//3
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show(testList.Count.ToString());//为啥是0?
}
先点击button2,再点击button3
为啥点击button3弹出的数会是0而不是3呢?原理不大明白,求大牛解释
private void button2_Click(object sender, EventArgs e)
{
ArrayList testList = new ArrayList();//
testList.Add("1");
testList.Add("2");
testList.Add("3");
MessageBox.Show(testList.Count.ToString());//3
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show(testList.Count.ToString());//为啥是0?
}
先点击button2,再点击button3
为啥点击button3弹出的数会是0而不是3呢?原理不大明白,求大牛解释