如何ArrayList里面再放ArrayList?
wtoeb 2007-01-20 06:47:00 以下是两个arraylist,第一个即Items,第二个即Item:
public struct Items
{
public int X;//第x层
public int Y;//第y列
public bool Z;//z是否显示
public Items(int x, int y,bool z)
{
X = x;
Y = y;
Z = z;
}
}
public struct Item
{
public int A;//第a层
public int B;//第b列
public bool C;//是否显示
public Item(int a, int b,bool c)
{
A = a;
B = b;
C = c;
}
}
现要求如:
当通过
ArrayList arr = new ArrayList();
arr.Clear();
arr.Add(new Items(0,0,false));//Items的第一项
arr.Add(new Items(0,1,false));//Items的第二项
arr.Add(new Items(1,0,false));//Items的第三项
arr.Add(new Items(1,1,false));//Items的第四项
后,可以对Items的第一项至第四项添加Item。即形成:
A B C X Y Z
0 0 false 数据0 数据a 数据p
0 0 false 数据1 数据b 数据q
0 0 false 数据2 数据c 数据r
0 0 false 数据3 数据d 数据s
0 0 false 数据4 数据e 数据t
……