C# 随机分组

1 var groups = targets.Select((item, index) => new { Item =item, GroupIndex = index % amount })
2                 .GroupBy(item => item.GroupIndex,
3                      (key, group) => group.Select(groupItem => groupItem.Item).ToList())
4                 .ToList();    

 

posted @ 2022-10-11 14:53  博二爷  阅读(68)  评论(0编辑  收藏  举报