英語で読む

次の方法で共有


Enumerable.Chunk<TSource>(IEnumerable<TSource>, Int32) メソッド

定義

シーケンスの要素を最大サイズの sizeチャンクに分割します。

C#
public static System.Collections.Generic.IEnumerable<TSource[]> Chunk<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, int size);

型パラメーター

TSource

source の要素の型。

パラメーター

source
IEnumerable<TSource>

IEnumerable<T>チャンクする要素を持つ 。

size
Int32

各チャンクの最大サイズ。

戻り値

IEnumerable<TSource[]>

IEnumerable<T>入力シーケンスがサイズ sizeのチャンクに分割された要素を格納する 。

例外

sourcenull です。

size は 1 未満です。

注釈

最後のチャンクを除く各チャンクのサイズ sizeは になります。 最後のチャンクには残りの要素が含まれており、サイズが小さい場合があります。

適用対象

製品 バージョン
.NET 6, 7, 8, 9

こちらもご覧ください