stuff ArrayList inside ArrayList or use DataTable
解决方案 »
- 我的SQL2008怎么打不开以前写的系统 是少装什么了吗?求助
- 如何从文本文件里 指定行数开始读,从最后开始读几行。。。
- 页面的日历,还有日程提醒功能如何实现。。。。。。。。。。。。【标题要长】
- 哈!webclient或这方面的使用!有难度,高手进!
- 2005.Net serialPort控件问题
- 用激光打印机在A4纸上打印入库单,想打印二份,能实现连打吗?
- 简单问题:请问C#里怎样退出当前函数啊?
- 谁有VC#的电子书籍呀?
- 给asp:Button加上背景
- 这么奇怪的问题!?
- DataGrid绑定的DataSet重新填充后,DataGrid其黑色三角游标不会自动跳到最上面?
- 从工具->选项里面可以建立以及建立快捷键方案, 请问哪里可以保存这些快捷方案, 好让我拿到公司里面用?
class Inventory
{
string one,two;
public Inventory(string s1,string s2)
{
one=s1;
two=s2;
}
public string toone()
{
return one;
}
public string totwo()
{
return two;
}
}
class InventoryList
{
public static void Main()
{
ArrayList inv=new ArrayList();
inv.Add(new Inventory("字符串1","字符串2"));
inv.Add(new Inventory("字符串1","字符串2"));
inv.Add(new Inventory("字符串1","字符串2"));
foreach(Inventory i in inv)
{
string str1=i.toone;
string str2=i.totwo;
......
}
}
}
ArrayList MainList = new ArrayList();ArrayList SubItem1 = new ArrayList();
SubItem1.Add("item11");
SubItem1.Add("item12");
SubItem1.Add("item13");ArrayList SubItem2 = new ArrayList();
SubItem2.Add("item21");
SubItem2.Add("item22");
SubItem2.Add("item23");MainList.Add(SubItem1);
MainList.Add(SubItem2);foreach(ArrayList SubItem in MainList)
{
foreach(string ItemValue in SubItem)
{
MessageBox.Show(ItemValue)
}
}
你要实现一个二维数组只要把ArrayList的每个元素改成一维数组就是了。
一维数组:
ArrayList arr1 = new ArrayList();
arr1.Add(1);
arr1.Add(2);
arr1.Add(3);
二维数组:
ArrayList arr2 = new ArrayList();
arr2.Add(new int[]{1,1});
arr2.Add(new int[]{2,2});
arr2.Add(new int[]{3,3});