EnumerablePrinter 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EnumerablePrinter --version 1.1.0
                    
NuGet\Install-Package EnumerablePrinter -Version 1.1.0
                    
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="EnumerablePrinter" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EnumerablePrinter" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="EnumerablePrinter" />
                    
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 EnumerablePrinter --version 1.1.0
                    
#r "nuget: EnumerablePrinter, 1.1.0"
                    
#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 EnumerablePrinter@1.1.0
                    
#: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=EnumerablePrinter&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=EnumerablePrinter&version=1.1.0
                    
Install as a Cake Tool

EnumerablePrinter

NuGet Version

Python‑inspired LINQ extensions for expressive, ergonomic collection handling in C#.

EnumerablePrinter brings the clarity and power of Python’s sequence operations to C#, with intuitive methods like Slice, Print, Chunk, and IsAlphabetical. Designed for developer ergonomics, deferred execution, and clean diagnostics.


✨ Latest Updates

  • Unified Square‑Bracket Formatting – All collections now print using [ ... ] for a clean, modern, JSON‑adjacent style.
  • Object Property Printing – Complex objects print their public properties automatically using a reflection‑based printer.
  • Dictionary Improvements – Key/value pairs print inline with consistent bracket formatting.
  • Nested Collection Support – Recursively prints arrays, lists, sets, and dictionaries with stable, predictable formatting.
  • Char Enumerable Special CaseIEnumerable<char> prints as a string literal instead of a character list.
  • Custom Formatting – User‑provided delegates are respected for all element types, including strings.
  • Output Redirection – Print to any TextWriter (console, file, buffer, logger).
  • Chunk Support – Split sequences into fixed‑size groups with lazy evaluation.
  • CRLF/LF Stability – All scripts and examples normalized to LF for cross‑platform reliability.
  • Automated Versioning – Repository scripts now auto‑increment semantic versions with cascading rollover.

✨ Features

Method Description
Print() Pretty‑print any IEnumerable<T> to console or TextWriter
IsAlphabetical() Check if a sequence is sorted alphabetically
Slice() Extract a subsequence like Python’s [start:end:step]
Chunk() Split a sequence into fixed‑size chunks

🚀 Installation

dotnet add package EnumerablePrinter

🧪 Test

dotnet test

Sample expectation:

Enumerable.Empty<int>().Print();
// Output: [ ]

🧰 Usage

Add:

using EnumerablePrinter;

and you're ready to go.


➤ Basic Usage

new[] { 1, 2, 3 }.Print();
// Output: [ 1, 2, 3 ]

➤ Empty Collections

Enumerable.Empty<int>().Print();
// Output: [ ]

➤ Printing a Dictionary

var dict = new Dictionary<string, int>
{
    ["Wayne"] = 1,
    ["Lucius"] = 2,
    ["Alfred"] = 3
};
dict.Print();
// Output:
// [ "Wayne": 1, "Lucius": 2, "Alfred": 3 ]

➤ Printing Nested Collections

var nested = new List<int[]>
{
    new[] { 1, 2 },
    new[] { 3, 4 }
};

nested.Print();
// Output:
// [ [ 1, 2 ], [ 3, 4 ] ]

➤ Combining Dictionaries and Nested Collections

var complex = new Dictionary<string, object>
{
    ["Numbers"] = new[] { 1, 2, 3 },
    ["Matrix"] = new List<int[]>
    {
        new[] { 1, 2 },
        new[] { 3, 4 }
    }
};
complex.Print();
// Output:
// [ "Numbers": [ 1, 2, 3 ], "Matrix": [ [ 1, 2 ], [ 3, 4 ] ] ]

➤ Printing Objects (Property Printing)

var products = new[]
{
    new Product { id = "1", name = "Keyboard", description = "Mechanical" }
};

products.Print();
// Output:
// [ [ id: 1, name: Keyboard, description: Mechanical ] ]

➤ With Custom Formatting

var names = new List<string> { "Wayne", "Lucius", "Alfred" };
names.Print(n => $"[{n}]");
// Output: [ [Wayne], [Lucius], [Alfred] ]

➤ Redirecting Output (e.g., logs or buffer)

using var writer = new StringWriter();
names.Print(n => n.ToUpper(), writer);
Console.WriteLine(writer.ToString());
// Output: [ WAYNE, LUCIUS, ALFRED ]

➤ Chunk Example

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

foreach (var chunk in data.Chunk(3))
{
    chunk.Print();
}

Output:

[ 1, 2, 3 ]
[ 4, 5, 6 ]
[ 7, 8, 9 ]
[ 10 ]

➤ IsAlphabetical Example

var names = new[] { "Alice", "Bob", "Charlie" };
names.IsAlphabetical(); // true

var unsorted = new[] { "Charlie", "Alice", "Bob" };
unsorted.IsAlphabetical(); // false

var people = new[]
{
    new Person { Name = "Alice" },
    new Person { Name = "Bob" },
    new Person { Name = "Charlie" }
};
people.IsAlphabetical(p => p.Name); // true

➤ Slice Example

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

data.Slice(2, 8);        // 3, 4, 5, 6, 7, 8
data.Slice(-3, null);    // 8, 9, 10
data.Slice(0, null, 2);  // 1, 3, 5, 7, 9


📝 License

Licensed under the MIT License.

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
1.1.1 90 1/11/2026
1.1.0 89 1/11/2026
1.0.6 177 10/13/2025
1.0.5 175 10/10/2025
1.0.3 174 10/2/2025
1.0.2 153 9/6/2025
1.0.1 188 7/10/2025