Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
サイズが不明な配列があり、それを小さなサイズの配列にフラグメント化したいと考えています。
たとえば、733 個の項目の配列は、7 つの 100 個の項目の配列と 1 つの 33 個の項目の配列のリストになります。
List<List<T>> Split(List<T> list, uint sublistsize)
これを行うコードを書くことはできますが、何かが組み込まれていますか?
static List<List<T>> Split<T>(IEnumerable<T> list, int sublistsize) { return list.Select((i, idx) => new { Item = i, Index = idx }) .GroupBy(x => x.Index / sublistsize) .Select(g => g.Select(x => x.Item).ToList()) .ToList(); }