C#怎么将List拆分成多个子集合
1个回答
展开全部
个人使用中的实例如下:
#region 新方法
List<List<hourhistoryrecorditem>> listGroup = new List<List<hourhistoryrecorditem>>();
int j = 500000;
for (int i = 0; i < lstVals.Count; i += 500000)//以50万为一组分组
{
List<hourhistoryrecorditem> cList = new List<hourhistoryrecorditem>();
cList = lstVals.Take(j).Skip(i).ToList();
j += 500000;
listGroup.Add(cList);
}
for (int i = 0; i < listGroup.Count; i++)
{
List<hourhistoryrecorditem> list = new List<hourhistoryrecorditem>();
list = listGroup[i];
foreach (hourhistoryrecorditem aItem in list)
{
int iOffset = 0;
DataRow r = dt.NewRow();
r[iOffset++] = DBNull.Value;
r[iOffset++] = aItem.CurValue;
r[iOffset++] = aItem.MaxValue_;
#region 新方法
List<List<hourhistoryrecorditem>> listGroup = new List<List<hourhistoryrecorditem>>();
int j = 500000;
for (int i = 0; i < lstVals.Count; i += 500000)//以50万为一组分组
{
List<hourhistoryrecorditem> cList = new List<hourhistoryrecorditem>();
cList = lstVals.Take(j).Skip(i).ToList();
j += 500000;
listGroup.Add(cList);
}
for (int i = 0; i < listGroup.Count; i++)
{
List<hourhistoryrecorditem> list = new List<hourhistoryrecorditem>();
list = listGroup[i];
foreach (hourhistoryrecorditem aItem in list)
{
int iOffset = 0;
DataRow r = dt.NewRow();
r[iOffset++] = DBNull.Value;
r[iOffset++] = aItem.CurValue;
r[iOffset++] = aItem.MaxValue_;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询