Soenneker.Extensions.List 11.0.1014

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.List

In-place replacement, removal, shuffling, random selection, and set conversion for List<T> and IList<T>.

Installation

dotnet add package Soenneker.Extensions.List

Replace or remove the first match

using Soenneker.Extensions.List;

var jobs = new List<Job> {queued, running, completed};

jobs.Replace(job => job.Id == updated.Id, updated);
jobs.Remove(job => job.Id == obsoleteId);

Replace() changes only the first match. Remove() removes only the first match and preserves the order of every remaining item. A null or empty list is a no-op. A null predicate throws only when the list contains items.

Use the state-aware RemoveAll() when every match should be removed without a closure allocation:

int removed = jobs.RemoveAll(
    static (job, state) => job.Status == (JobStatus)state!,
    JobStatus.Completed);

RemoveAll() compacts survivors in place, preserves their order, and returns the number removed. The list and predicate must not be mutated recursively while any of these operations are evaluating the predicate.

Shuffle in place

items.Shuffle();       // fast, non-cryptographic
items.SecureShuffle(); // cryptographic random source

Both methods use an unbiased Fisher-Yates shuffle and modify the supplied writable IList<T>. Null lists and lists with fewer than two items are unchanged. Shuffle() is appropriate for presentation order, retry spreading, and games that do not involve security. Use SecureShuffle() when the permutation must not be predictable, such as drawing prizes or security-sensitive assignments.

Neither method returns a copy. Create one first when the original order must be retained:

var shuffled = new List<Card>(deck);
shuffled.Shuffle();

Select one item

Server? server = servers.GetRandom();

GetRandom() uses the same fast, non-cryptographic source as Shuffle(). It returns default(T) for a null or empty list, so the result cannot distinguish an empty list from a list whose selected element is itself null or the value-type default.

Create a set

HashSet<string> names = values.ToHashSet(StringComparer.OrdinalIgnoreCase);

ToHashSet() returns a new set and removes duplicates according to the supplied comparer, or EqualityComparer<T>.Default when none is supplied. A null or empty list returns an empty set configured with that comparer. Later changes to the list and set are independent.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Soenneker.Extensions.List:

Package Downloads
Soenneker.Blazor.TomSelect

A Blazor interop library for the select user control library, Tom Select

Soenneker.Blazor.FilePond

A Blazor interop library for the file upload library FilePond

Soenneker.GitHub.Repositories.PullRequests

Retrieves, reviews, rebases, and merges GitHub pull requests across repositories

Soenneker.Extensions.Collection

Helpful Collection extension methods

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1014 1,008 11/11/2026
11.0.1013 186 11/11/2026
11.0.1012 256 11/10/2026
11.0.1011 2,102 11/3/2026
11.0.1010 1,854 10/26/2026
11.0.1009 104 10/26/2026
4.0.1008 428 10/26/2026
4.0.1007 2,042 10/15/2026
4.0.1006 649 10/14/2026
4.0.1004 147 10/14/2026
4.0.999 275 10/13/2026
4.0.998 150 10/12/2026
4.0.997 319 10/12/2026
4.0.996 545 10/11/2026
4.0.995 223 10/11/2026
4.0.994 3,514 9/24/2026
4.0.993 138 9/24/2026
4.0.992 1,880 9/15/2026
4.0.991 308 9/15/2026
4.0.990 1,359 9/13/2026
Loading failed

Update dependency Soenneker.Utils.Random to 11.0.150 (#1555)