C# group list via GetRange

var dataItems = dg.ItemsSource?.Cast<Book>()?.ToList();
List<List<Book>> booksListList = new List<List<Book>>();
for (int i = 0; i < dataItems.Count; i += 10000)
{
    booksListList.Add(dataItems.GetRange(i, Math.Min(10000, dataItems.Count - i)));
}

 

posted @ 2024-05-20 20:26  FredGrit  阅读(2)  评论(0编辑  收藏  举报