Philiprehberger.ChunkList 0.1.10

dotnet add package Philiprehberger.ChunkList --version 0.1.10
                    
NuGet\Install-Package Philiprehberger.ChunkList -Version 0.1.10
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Philiprehberger.ChunkList" Version="0.1.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Philiprehberger.ChunkList" Version="0.1.10" />
                    
Directory.Packages.props
<PackageReference Include="Philiprehberger.ChunkList" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Philiprehberger.ChunkList --version 0.1.10
                    
#r "nuget: Philiprehberger.ChunkList, 0.1.10"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Philiprehberger.ChunkList@0.1.10
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Philiprehberger.ChunkList&version=0.1.10
                    
Install as a Cake Addin
#tool nuget:?package=Philiprehberger.ChunkList&version=0.1.10
                    
Install as a Cake Tool

Philiprehberger.ChunkList

CI NuGet Last updated

Split any IEnumerable into fixed-size chunks with a simple static method or LINQ-style extension.

Installation

dotnet add package Philiprehberger.ChunkList

Usage

using Philiprehberger.ChunkList;

var numbers = Enumerable.Range(1, 10);

// Static method
foreach (var chunk in EnumerableChunker.Chunk(numbers, 3))
{
    Console.WriteLine(string.Join(", ", chunk));
}
// 1, 2, 3
// 4, 5, 6
// 7, 8, 9
// 10

// Extension method
var chunks = numbers.ChunkBy(4).ToList();
// chunks[0] == [1, 2, 3, 4]
// chunks[1] == [5, 6, 7, 8]
// chunks[2] == [9, 10]

// Works with any sequence
var words = new[] { "a", "b", "c", "d", "e" };
var pairs = words.ChunkBy(2);
// ["a","b"], ["c","d"], ["e"]

Custom Chunk Size

using Philiprehberger.ChunkList;

var items = Enumerable.Range(1, 10);
var pairs = EnumerableChunker.Chunk(items, 2);
// [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]

Extension Method

using Philiprehberger.ChunkList;

var names = new[] { "Alice", "Bob", "Charlie", "Dave", "Eve" };
foreach (var group in names.ChunkBy(2))
{
    Console.WriteLine(string.Join(", ", group));
}
// Alice, Bob
// Charlie, Dave
// Eve

Edge Cases

using Philiprehberger.ChunkList;

var empty = Array.Empty<int>().ChunkBy(3); // yields nothing
var small = new[] { 1, 2 }.ChunkBy(5);    // [[1, 2]] — single chunk

API

EnumerableChunker

Method Description
Chunk<T>(IEnumerable<T> source, int size) Yield IReadOnlyList<T> chunks of at most size elements

ChunkExtensions

Method Description
ChunkBy<T>(this IEnumerable<T> source, int size) Extension method — same as EnumerableChunker.Chunk

Notes:

  • The last chunk may contain fewer than size elements.
  • Throws ArgumentOutOfRangeException if size is zero or negative.
  • Enumeration is lazy — chunks are produced on demand.

Development

dotnet build src/Philiprehberger.ChunkList.csproj --configuration Release

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.10 120 4/1/2026
0.1.9 111 3/27/2026
0.1.8 105 3/25/2026
0.1.7 105 3/23/2026
0.1.6 106 3/21/2026
0.1.5 112 3/20/2026
0.1.4 132 3/16/2026
0.1.3 116 3/16/2026
0.1.2 116 3/16/2026
0.1.1 125 3/11/2026
0.1.0 119 3/11/2026