水平很菜,自己捣鼓了很长时间才弄出来的~
你自己看看吧~
ArrayList al = new ArrayList();
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine("--------------------------");
Random r = new Random();
int randomNum = r.Next(1, 10);
Console.WriteLine(al.Contains(randomNum));
if (!al.Contains(randomNum))
{
Console.WriteLine("-- {0}", randomNum);
Console.WriteLine("-- {0}", al.Count);
al.Add(randomNum);
}
}
private void button2_Click(object sender, EventArgs e)
{
Console.WriteLine(">>>>>>>>>>>---{0}", al.Count);
for (int i = 0; i < al.Count; i++)
{
Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>{0}", al[i]);
}
}