FunctionalEnumerableExtensions 1.0.10

dotnet add package FunctionalEnumerableExtensions --version 1.0.10
                    
NuGet\Install-Package FunctionalEnumerableExtensions -Version 1.0.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="FunctionalEnumerableExtensions" Version="1.0.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FunctionalEnumerableExtensions" Version="1.0.10" />
                    
Directory.Packages.props
<PackageReference Include="FunctionalEnumerableExtensions" />
                    
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 FunctionalEnumerableExtensions --version 1.0.10
                    
#r "nuget: FunctionalEnumerableExtensions, 1.0.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 FunctionalEnumerableExtensions@1.0.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=FunctionalEnumerableExtensions&version=1.0.10
                    
Install as a Cake Addin
#tool nuget:?package=FunctionalEnumerableExtensions&version=1.0.10
                    
Install as a Cake Tool

FunctionalEnumerableExtensions 🌟

FunctionalEnumerableExtensions is a C# class library that provides a set of extension methods for working with enumerable collections. These extensions are designed to enhance memory efficiency and make common operations more convenient. Whether you're converting to lists, arrays, or working with spans, these extensions aim to improve your code's performance and readability.

Installation 🚀

To easily integrate the FunctionalEnumerableExtensions library into your project, you can use NuGet Package Manager. NuGet is a package manager for .NET that simplifies the process of adding, removing, and updating libraries in your applications.

After that import the FunctionalEnumerableExtensions namespace in your code files where you want to use the provided extension methods:

using FunctionalEnumerableExtensions;

Available Extension Methods 🛠️

EnsureList

Prevent memory allocation when converting to a list using LINQ's .ToList().

Usage:

List<int> myList = myEnumerable.EnsureList();

EnsureArray

Prevent memory allocation when converting to an array using LINQ's .ToArray().

Usage:

T[] myArray = myEnumerable.EnsureArray();

AsSpan

Warning: DO NOT use Span if you would change the list while looping into it, it can cause exceptions.

Convert the enumerable collection to a Span, suitable for in-place data processing.

Usage:

Span<T> mySpan = myEnumerable.AsSpan();

EnsureHashSet

Prevent memory allocation by casting an IEnumerable to a HashSet<T> if it's already of that type, otherwise create a new HashSet<T>.

Usage:

HashSet<T> myHashSet = myEnumerable.EnsureHashSet();

CollectNonNulls

Filter out non-null items from the input IEnumerable<T>.

Usage:

var myFilteredList = myEnumerable.CollectNonNulls();

EnsureEnumerable

Prevent the enumerable to be null.

Usage:

var myNotNullEnumerable = myEnumerable.EnsureEnumerable();

SplitBy

Splits the list according to the predicate.

Usage:

var (desiredItems, remainingItems) = enumerable.SplitBy(customer => customer.LoyaltyTimeInYears > 20);

IsNullOrEmpty

Checks if the list is null or empty

Usage:

var result = enumerable.IsNullOrEmpty();

WhereIf

Introduces optional filtering, applying a predicate only if a specified condition holds true.

Usage:

var result = enumerable.WhereIf(YourBooleanCondition(), w => w > 0);

Stringify

Converts a collection of non-null objects to a string by concatenating their properties recursively, separated by commas.

Usage:

var result = enumerable.Stringify();

EnumerateWithIndex

Enumerate an IEnumerable source and getting the Index and the Item returned in a ValueTuple.

Usage

var result = enumerable.EnumerateWithIndex();

JoinString

Chainable method that joins the separator string with the items of your Enumerable.

Usage

var result = list.Select(s => s.Name).JoinString();

OrderBy and OrderByDescending with a delegate comparer

Sorts the elements of a sequence in ascending/descending order by using a specified comparer.

Usage

record Customer(string Name, int Age);

//Order by name then by age
//user OrderByDescending to order descendingly
var result = values.OrderBy(x => (x.Name, x.Age), (a, b) =>
        {
            var nameComparison = string.Compare(a.Name, b.Name, StringComparison.Ordinal);
            return nameComparison != 0 ? nameComparison : a.Age.CompareTo(b.Age);
        });
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • 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.0.10 106 7/30/2024
1.0.9 128 6/26/2024
1.0.8 144 3/6/2024
1.0.7 131 2/29/2024
1.0.6 159 1/28/2024
1.0.5 130 1/27/2024
1.0.4 192 12/18/2023
1.0.3 195 10/27/2023
1.0.2 175 8/23/2023
1.0.1 198 8/15/2023
1.0.0 193 8/11/2023