分割List集合
![]()
//构造被分隔的集合
List<object> list = new List<object>();
for (int i = 0; i <= 100; i++)
{
list.Add(i);
}
//待导入集合组
List<IEnumerable<object>> BigList = new List<IEnumerable<object>>();
//定义批次分组提交量
int groupItemCount = 10;
//被分隔集合的总数量
int totalCount = list.Count();
//一共被分几组
int count = totalCount % groupItemCount == 0 ? totalCount / groupItemCount : totalCount / groupItemCount + 1;
//将每一组都添加进大集合
for (int i = 0; i < count; i++)
{
BigList.Add(list.Skip(groupItemCount * i).Take(groupItemCount));
}
foreach (IEnumerable<object> enumList in BigList)
{
//每一个enumList都一个10个int数据的集合
foreach (int a in enumList)
{
//dosomething
}
}
View Code