Split a List into smaller lists of N size

前端 未结 17 1854
后悔当初
后悔当初 2020-11-22 16:55

I am attempting to split a list into a series of smaller lists.

My Problem: My function to split lists doesn\'t split them into lists of the correct

17条回答
  •  我在风中等你
    2020-11-22 17:51

    List orginalList =new List(){1,2,3,4,5,6,7,8,9,10,12};
    Dictionary> dic = new Dictionary > ();
    int batchcount = orginalList.Count/2; //To List into two 2 parts if you 
     want three give three
    List lst = new List();
    for (int i=0;i();**strong text**
    threadId++;
    }
    }
    if(lst.Count>0)
    Dic.Add(threadId, lst); //in case if any dayleft 
    foreach(int BatchId in Dic.Keys)
    {
      Console.Writeline("BatchId:"+BatchId);
      Console.Writeline('Batch Count:"+Dic[BatchId].Count);
    }
    

提交回复
热议问题