AlastairLundy.EnhancedLinq
0.2.0
Prefix Reserved
dotnet add package AlastairLundy.EnhancedLinq --version 0.2.0
NuGet\Install-Package AlastairLundy.EnhancedLinq -Version 0.2.0
<PackageReference Include="AlastairLundy.EnhancedLinq" Version="0.2.0" />
<PackageVersion Include="AlastairLundy.EnhancedLinq" Version="0.2.0" />
<PackageReference Include="AlastairLundy.EnhancedLinq" />
paket add AlastairLundy.EnhancedLinq --version 0.2.0
#r "nuget: AlastairLundy.EnhancedLinq, 0.2.0"
#:package AlastairLundy.EnhancedLinq@0.2.0
#addin nuget:?package=AlastairLundy.EnhancedLinq&version=0.2.0
#tool nuget:?package=AlastairLundy.EnhancedLinq&version=0.2.0
EnhancedLinq
This library adds Additional LINQ style Deferred execution and Immediate enumeration mode extension methods for .NET .
🚀 Included Methods
For a comprehensive list of included methods, check out the following resources:
📦 NuGet Packages
EnhancedLinq comes with several packages tailored to your needs:
EnhancedLinq
: The core package that enhances your LINQ experience.EnhancedLinq.Memory
: Specifically forSpan<T>
andMemory<T>
, providing helpful immediate mode extensions.EnhancedLinq.MsExtensions
: Focused onStringSegment
fromMicrosoft.Extensions.Primitives
, with plans to potentially expand support for other Microsoft.Extensions packages.
🛠️ Installing EnhancedLinq
Getting started with EnhancedLinq is easy! You can install the packages using the .NET SDK CLI, your IDE's package manager, or directly from the NuGet website.
Package Id | NuGet Link | .NET SDK CLI Command |
---|---|---|
AlastairLundy.EnhancedLinq.MsExtensions | EnhancedLinq NuGet | dotnet add package AlastairLundy.EnhancedLinq. |
AlastairLundy.EnhancedLinq.EnhancedLinq.Memory | EnhancedLinq.Memory NuGet | dotnet add package AlastairLundy.EnhancedLinq.Memory |
AlastairLundy.EnhancedLinq.EnhancedLinq.MsExtensions | EnhancedLinq.MsExtensions NuGet | dotnet add package AlastairLundy.EnhancedLinq.MsExtensions |
📖 Usage
Here are some examples demonstrating how to use some methods provided by EnhancedLinq.
Deferred Execution Examples
ElementsAt This example shows how to find the elements at a given sequence of indices.
var fruits = ["Apple", "Banana", "Cherry", "Date", "Elderberry" ];
var indices = [1, 3]; // We want to retrieve "Banana" and "Date"
IEnumerable<string> selectedFruits = fruits.ElementsAt(indices);
Console.WriteLine("Selected Fruits:");
foreach (string fruit in selectedFruits)
{
Console.WriteLine(fruit); // Outputs: Banana, Date
}
IndicesOf This example shows how to find all the indices of a specific element in an IEnumerable<T>.
var numbers = [ 1, 2, 3, 2, 4, 2, 5 ];
int target = 2; // We want to find the indices of the number 2
IEnumerable<int> indices = numbers.IndicesOf(target);
Console.WriteLine("Indices of target element:");
foreach (var index in indices)
{
Console.WriteLine(index); // Outputs: 1, 3, 5
}
Immediate Enumeration Mode Examples
ContainsDuplicates This example shows how to check if an IEnumerable<T> contains any duplicate elements.
var fruits = ["Apple", "Banana", "Cherry", "Apple" ]; // Contains a duplicate
bool hasDuplicates = fruits.ContainsDuplicates();
Console.WriteLine($"Does the list contain duplicates? {hasDuplicates}"); // Output: True
IndexOf This example shows how to find the index of the first element that matches a predicate in an IEnumerable<T>.
var numbers = new List<int> { 10, 20, 30, 40, 50 };
// Define a predicate to find the first number greater than 25
Func<int, bool> predicate = n => n > 25;
int index = numbers.IndexOf(predicate);
Console.WriteLine($"Zero based index of the first element greater than 25: {index}"); // Output: 2
🏗️ Building
To build EnhancedLinq from source, follow these steps:
- Clone the repository.
- Open the solution in your preferred IDE or Code Editor.
- Build the desired project to restore dependencies and compile the project.
🤝 Contributing
I welcome contributions. If you have ideas for new features, improvements, or bug fixes, please check out the contributing guidelines for more information.
📜 License
EnhancedLinq is licensed under the Mozilla Public License 2.0. Feel free to use and modify EnhancedLinq according to the terms of the license.
❓ Questions?
If you have any questions or experience any issues, please open an issue in the repository's GitHub issues page.
🔄 Alternatives
While EnhancedLinq is a powerful tool, you may also want to explore these alternatives:
Product | Versions 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 is compatible. 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. |
-
net8.0
- AlastairLundy.DotExtensions (>= 8.2.0)
- AlastairLundy.DotPrimitives.Collections (>= 3.1.0)
-
net9.0
- AlastairLundy.DotExtensions (>= 8.2.0)
- AlastairLundy.DotPrimitives.Collections (>= 3.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
### Changes since 0.1.0
* Changed root namespace
* Added ``LastIndexOf`` immediate mode extension methods