+ -
当前位置:首页 → 问答吧 → 请教两个问题,一个是DataTable.Rows.Count,一个关于遍历

请教两个问题,一个是DataTable.Rows.Count,一个关于遍历

时间:2011-12-11

来源:互联网

1、C# code

List<string> temp = new List<string>();
foreach (DataRow row in dt.Rows)
{
    for (int i = 0; i < row.ItemArray.Length; i++)
    {
        temp.Add(row.ItemArray[i].ToString());
    }                            
}


其中dt是DataTable。
我设置断点跟进去时,为什么dt.Rows.Count是个只读的值1000?如果我数据行是3000,如何改进?

2、C# code

for(int n=0; n < 100; n++)
{
   List<string> temp1 = new List<string>();
   List<string> temp2 = new List<string>();
   temp1.Add(n.ToString());
   temp2.Add((n + 1).ToString());
}
int m=0;


现在我要作一个统计,只要temp1中的数temp2中也有,m就加1。
如temp1={"1","2","3","5"},temp2={"1","2","4","5","9","10","15"},那么m=3。
怎么实现?(有可能temp1、temp2中的数都在10000以上,考虑效率)

作者: liangming1989   发布时间: 2011-12-11

求救啊!

作者: liangming1989   发布时间: 2011-12-11

相关阅读 更多