v2.0.3 stable / For .NET 8 and later

Familiar collections.
Native C#.

Write less boilerplate. Build expressive pipelines. Bring familiar Filter, Map, and Reduce methods to .NET with strong types, optimized operations, and zero package dependencies.

dotnet add package collection-iterable-methods

Open source · MIT licensed · No package dependencies

Program.csC# / .NET 8+
using CollectionIterable;

var numbers = new[] { 1, 2, 3, 4, 5, 6 };

var labels = numbers
    .Filter(n => n % 2 == 0)
    .Map(n => $"Item {n}")
    .ToArray();

// ["Item 2", "Item 4", "Item 6"]
A small transformation.Filter(n => n % 2 == 0)
123456246
01 / Familiar

Names you know.
Types you can trust.

02 / Composable

Arrays, lists, and streams.
Works alongside LINQ.

03 / Powerful

Optimized collection operations.
Async and parallel, built in.

Getting started

From install
to your first result.

Works with .NET 8, .NET 9, .NET 10, and later compatible versions. Add the package, import a namespace, and use the methods directly on your collection.

View package on NuGet ↗
1

Add the package

dotnet add package collection-iterable-methods --version 2.0.3
2

Import and transform

using CollectionIterable;

var total = new[] { 10, 20, 30 }
    .Filter(price => price > 10)
    .Reduce((sum, price) => sum + price, 0);

// 50
3

Keep using the .NET tools you know

Results are ordinary .NET values and collections. Chain lazy results with LINQ, or materialize them with ToArray() when you need a snapshot.

Built for the way you work

One toolkit. More ways to build.

Compose elegant pipelines, await CPU work,
and put parallel processing to work.

Lazy & ordered

Transform now.
Enumerate when ready.

Filter and Map defer work until enumeration. Map between different types without losing inference.

Indexed callbacks are available too. Use Map((value, index) => ...) when position matters.

Typed transformations
using CollectionIterable;

var names = new[] { "Ada", "Linus", "Grace" };
var labels = names
    .Filter(name => name.Length > 3)
    .Map((name, index) => $"{index + 1}. {name}")
    .ToArray();

// ["1. Linus", "2. Grace"]
Awaitable completion

Put CPU work
on a worker thread.

FilterAsync runs a synchronous predicate on a worker thread and materializes the result before the task completes.

Keep your calling thread free while synchronous callbacks run in the background. Await the task to access completed results.

Await a completed result
using CollectionIterableAsync;

var numbers = new[] { 1, 2, 3, 4, 5, 6 };
var evens = await numbers.FilterAsync(n => n % 2 == 0);

// Work is finished when await returns.
// evens contains 2, 4, 6.
Concurrent callbacks

Put parallel processing
to work.

Use IIterableOptions to set the degree of parallelism and a cancellation token.

Choose the concurrency level that fits your application, with cooperative cancellation built in. See the API guide for callback and ordering requirements.

Bounded parallel filtering
using CollectionIterableParallel;
using CollectionIterableUtils;

using var cancellation = new CancellationTokenSource();
var options = new IIterableOptions
{
    parallelOptions = new ParallelOptions
    {
        MaxDegreeOfParallelism = 4
    },
    cancellationToken = cancellation.Token
};
var evens = new[] { 1, 2, 3, 4, 5, 6 }
    .FilterParallel(n => n % 2 == 0, options);

// Contains 2, 4, 6. Order is unspecified.

API at a glance

Your collection toolkit, ready to go.

From a quick filter to a complete pipeline,
find the operation you need.

MethodPurposeWhat you get
Filter / MapKeep matching items / transform typesLazy, ordered; replayable if the source is
SliceSelect a rangeEfficient, bounded enumeration of a range
Reduce / ForEachAccumulate a value / visit each itemComplete synchronously
ConcatJoin two collectionsImmediate copy for arrays/collections; lazy for general enumerables
ToRecordCreate a dictionaryDirect key/value projection into a dictionary
SortCollectionSort by a keyCached sort keys while preserving the source collection
FilterAsync / ConcatAsync / ForEachAsyncOffload synchronous workTask.Run; work completes before await returns
FilterParallel / FilterParallelAsyncFilter concurrentlyComplete before return/await; unordered output
ForEachParallel / ForEachParallelAsyncVisit items concurrentlyConfigurable parallelism for concurrent processing
SortCollectionParallelSort with a parallel pathAdaptive sorting with sequential and parallel paths
ToDictionaryParallelCreate a dictionary concurrentlyConcurrent dictionary construction with an IDictionary result

Namespaces
CollectionIterable · CollectionIterableAsync · CollectionIterableParallel · CollectionIterableUtils

Cancellation & concurrency
Cancellation is cooperative. Either supplied token can cancel; options are copied, never mutated. Default maximum parallelism is five.

Performance you can measure

Less time transforming.
More time building.

Map up to 9.89× faster, filter up to 4.61× faster, and slice up to 12.43× faster in the recorded comparison. Optimized core operations make readable collection code even more rewarding.

Read the full benchmark report ↗
156workloads in the comparison

Two final comparison runs. Explore the measured gains operation by operation.

Selected-operation peaks across tested inputs, comparing 2.0 candidate source with 1.0.2 source. Full methodology and results in the report.

Discover version 2

More expressive.
Ready for your next idea.

Transform between types with generalized Map, await completed collection results, and manage parallel operations with configurable cancellation.

Map between types with automatic inference

Turn numbers into labels, records into view models, and raw values into the shapes your application needs. C# infers both types for concise, expressive code.

Await collection results with confidence

Async filtering and concatenation finish their work before the task completes, giving you results that are ready to use.

Configure parallel work in one place

Set concurrency and cancellation through IIterableOptions. Use ForEachParallelAsync to await parallel iteration and observe completion.

API details & upgrade guide ↗

Part of your .NET toolkit

Make the next transformation readable.

Install in seconds. Start with a familiar method. Build a pipeline your team will love to read.

Get started