FunctionalEnumerableExtensions 1.0.10
dotnet add package FunctionalEnumerableExtensions --version 1.0.10
NuGet\Install-Package FunctionalEnumerableExtensions -Version 1.0.10
<PackageReference Include="FunctionalEnumerableExtensions" Version="1.0.10" />
<PackageVersion Include="FunctionalEnumerableExtensions" Version="1.0.10" />
<PackageReference Include="FunctionalEnumerableExtensions" />
paket add FunctionalEnumerableExtensions --version 1.0.10
#r "nuget: FunctionalEnumerableExtensions, 1.0.10"
#:package FunctionalEnumerableExtensions@1.0.10
#addin nuget:?package=FunctionalEnumerableExtensions&version=1.0.10
#tool nuget:?package=FunctionalEnumerableExtensions&version=1.0.10
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 | Versions 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. |
-
.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.