Pipe4Net 1.4.0

.NET Standard 2.0
dotnet add package Pipe4Net --version 1.4.0
NuGet\Install-Package Pipe4Net -Version 1.4.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="Pipe4Net" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pipe4Net --version 1.4.0
#r "nuget: Pipe4Net, 1.4.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.
// Install Pipe4Net as a Cake Addin
#addin nuget:?package=Pipe4Net&version=1.4.0

// Install Pipe4Net as a Cake Tool
#tool nuget:?package=Pipe4Net&version=1.4.0


Inspired by PowerShell, two extension methods that will simplify your code, Pipe and PipeWith

Package manager: Install-Package Pipe4Net

.NET CLI: dotnet add package Pipe4Net

-- Update 16.10.2018 v1.3

For better redability added:

PipeResultTo same as Pipe

EndWith same as PipeWith

added new extension method on int : GenerateForLoopWithIndex((i) ⇒ cw(i)) where i is the current index in for loop, zero based! runs from i = 0 to i < targetInt

var result = IncrementA(IncrementB(IncrementC(1)))


var pipedResult2 = IncrementC(1).Pipe(IncrementB).Pipe(IncrementA);

You will find another goodie in there , an Option<T> monad in case you need it.

Two useful extension methods on bool type:


Ex: ReturnBoolValue().IfTrue(() => Console.WriteLine("True")).Else(() => Console.WriteLine("False"));

No need for temp variables or { } block statements

The code is pretty simple, i encourage you to play and extend it by your own needs

public static class PipeIt
    public static void PipeWith<T>(this T obj, Action<T> action) => action(obj);
    public static T Pipe<T>(this T obj, Func<T, T> func) => func(obj);

    public static Option<TR> Pipe<T,TR>(this T obj, Func<T, Option<TR>> func) => func(obj);

This is the main reason why this package exists. Look at the other tests also they are pretty intuitive

    public void Should_Have_Same_Result_When_Piped()
        var result = IncrementA(IncrementB(IncrementC(1)));

        var pipedResult = 1.Pipe(IncrementC).Pipe(IncrementB).Pipe(IncrementC);


        var pipedResult2 = IncrementC(1).Pipe(IncrementB).Pipe(IncrementA);

        Assert.Equal(result, pipedResult2);

    private int IncrementA(int val) => val++;

    private int IncrementB(int val) => val++;

    private int IncrementC(int val) => val++;

The test above perfectly represents what i want to achieve with this nuget package, i have reading code from right to left, or naming temporary variables, it just one of those things that bothers me in programming, and i think this way or writing code is more elegant:

var result = IncrementA(IncrementB(IncrementC(1))) becomes var pipedResult2 = IncrementC(1).Pipe(IncrementB).Pipe(IncrementA);


Some extensions methods on arrays that will make your code easier to read:

  • .ForEach implementation for arrays
  • .DeepCopy
  • .ShallowCopy
  • .AreSameByValue
  • .AreSameByReference
  • .AreSameByValueAndIndex
  • .RemoveElements
  • .RemoveElement
  • .AddElements
  • .AddElement
  • .RemoveNulls
  • .ForEachWithIndex
  • .Split

One extension method on int:

  • .GenerateForLoop
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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.4.0 565 3/8/2019
1.3.0 593 10/16/2018
1.2.1 701 8/15/2018
1.2.0 677 8/12/2018
1.1.5 696 8/11/2018
1.1.4 693 8/10/2018
1.1.3 657 8/8/2018
1.1.2 658 8/8/2018
1.1.0 697 8/8/2018
1.0.0 670 8/2/2018