分割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

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2021-11-19
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-05-03
猜你喜欢
  • 2021-05-17
  • 2021-11-03
  • 2021-07-24
  • 2021-10-24
  • 2021-07-01
  • 2021-04-23
  • 2021-05-22
相关资源
相似解决方案