Enumerable.Chunk<TSource>(IEnumerable<TSource>, Int32) 方法

定义

将序列的元素拆分为最大 size大小的区块。

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<cli::array <TSource> ^> ^ Chunk(System::Collections::Generic::IEnumerable<TSource> ^ source, int size);
public static System.Collections.Generic.IEnumerable<TSource[]> Chunk<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, int size);
static member Chunk : seq<'Source> * int -> seq<'Source[]>
<Extension()>
Public Function Chunk(Of TSource) (source As IEnumerable(Of TSource), size As Integer) As IEnumerable(Of TSource())

类型参数

TSource

source 的元素类型。

参数

source
IEnumerable<TSource>

IEnumerable<T> 分块的元素的 。

size
Int32

每个区块的最大大小。

返回

IEnumerable<TSource[]>

一个 , IEnumerable<T> 包含输入序列拆分为大小 size区块的元素。

例外

sourcenull

size 小于 1。

注解

每个区块(最后一个区块除外)的大小为 size。 最后一个区块将包含剩余的元素,大小可能较小。

适用于

另请参阅