Soenneker.Extensions.Collection 11.0.1477

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

Mutating helpers for removing matching items from ICollection<T> and conditionally adding non-null values.

Installation

dotnet add package Soenneker.Extensions.Collection

Remove multiple values

using Soenneker.Extensions.Collection;

var names = new List<string> { "Alpha", "Beta", "ALPHA", "Gamma" };

names.RemoveEnumerableFromCollection(
    ["alpha", "gamma"],
    StringComparer.OrdinalIgnoreCase);

// names contains only "Beta"

RemoveEnumerableFromCollection() mutates the target and removes every occurrence that matches any supplied removal value. Missing values are ignored. The removal sequence is materialized before the target changes, so it is safe to pass the same collection as both arguments.

Equality selection is explicit:

  • A supplied IEqualityComparer<T> is honored for List<T>, HashSet<T>, and other ICollection<T> implementations.
  • Without one, a HashSet<T> target uses its own comparer.
  • Other target types use EqualityComparer<T>.Default.

The method creates a HashSet<T> of removal values. Lists and hash sets use optimized in-place removal. Other collection types are scanned into a temporary list before removal, avoiding mutation during enumeration and ensuring duplicate matching elements are all removed.

Null or empty target/removal collections are no-ops. A read-only collection still throws from its own Remove implementation when a match is found. The method provides no locking; callers must synchronize concurrent mutation.

For a short inline list, RemoveFromCollection() is a params convenience wrapper:

names.RemoveFromCollection("Beta", "Gamma");

Add non-null values

var recipients = new List<string>();
string? optionalAddress = GetAddress();

recipients.AddIfNotNull(optionalAddress);

AddIfNotNull() skips a null reference or nullable value and otherwise calls the target collection's Add. It does not prevent duplicates, validate the value, or suppress exceptions from a read-only/fixed-size collection. Non-nullable value types are always added, including their default value.

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

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
11.0.1477 139 11/11/2026
11.0.1476 72 11/11/2026
11.0.1475 63 11/11/2026
11.0.1474 59 11/10/2026
11.0.1473 62 11/10/2026
11.0.1472 369 11/3/2026
11.0.1471 146 10/27/2026
11.0.1470 98 10/26/2026
11.0.1469 88 10/26/2026
11.0.1468 98 10/26/2026
4.0.1466 140 10/15/2026
4.0.1465 103 10/14/2026
4.0.1464 104 10/14/2026
4.0.1462 101 10/14/2026
4.0.1456 112 10/13/2026
4.0.1455 108 10/12/2026
4.0.1453 104 10/12/2026
4.0.1452 116 10/11/2026
4.0.1451 107 10/11/2026
4.0.1450 111 10/11/2026
Loading failed

Update dependency Soenneker.Extensions.List to 11.0.1014 (#1891)