作者tina96391 (AIR)
看板C_Sharp
标题[问题] ArrayList中取得值的问题
时间Fri May 1 22:31:23 2015
写程式的新手,想问各位大大一个问题><
附上程式一个片段:
private void button2_Click(object sender, EventArgs e)
{
ArrayList list = new ArrayList();
for (int i = 0; i < 10; i++)
{
a = new myCircle(this.CreateGraphics(),
this.ClientSize.Width, this.ClientSize.Height);
list.Add(a);
Thread.Sleep(600);
}
Thread thread1 = new Thread(new ThreadStart(checkDistance));
thread1.Start();
}
如上,myCircle是自己写的class,里面有x和y会一直不停变换。
按下button2後萤幕会出现十颗球。
我的问题是,要怎麽从arraylist里面抓出十颗球个别的x和y位置,谢谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.168.200.241
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1430490686.A.025.html
1F:推 GoalBased: 请用list 05/01 23:21
2F:→ GoalBased: 或者(myCircle)list[0] 对ArrayList里面的物件做转型 05/01 23:22
3F:推 J002: 楼上中肯! 用List<myCircle> 05/02 00:16
4F:→ GoalBased: 补充一下,如果你有看一些C#的文件或书 05/02 00:26
5F:→ GoalBased: 在讲到型别的时候都会推荐你用List来代替Array或 05/02 00:26
6F:→ GoalBased: ArrayList,至於为什麽就请你自己去看资料了 05/02 00:27
7F:推 neo5277: 记得是箱子问题? 05/02 02:15