Soenneker.Extensions.Collection 4.0.1441

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.Collection --version 4.0.1441
                    
NuGet\Install-Package Soenneker.Extensions.Collection -Version 4.0.1441
                    
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="4.0.1441" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.Collection" Version="4.0.1441" />
                    
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 4.0.1441
                    
#r "nuget: Soenneker.Extensions.Collection, 4.0.1441"
                    
#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@4.0.1441
                    
#: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=4.0.1441
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.Collection&version=4.0.1441
                    
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 net10.0 is compatible.  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. 
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
4.0.1447 95 9/15/2026
4.0.1446 86 9/15/2026
4.0.1444 88 9/13/2026
4.0.1443 94 9/12/2026
4.0.1442 93 9/12/2026
4.0.1441 110 9/8/2026
4.0.1440 100 9/7/2026
4.0.1439 117 8/31/2026
4.0.1438 100 8/30/2026
4.0.1437 101 8/30/2026
4.0.1436 105 8/30/2026
4.0.1435 101 8/29/2026
4.0.1434 104 8/29/2026
4.0.1433 98 8/29/2026
4.0.1432 109 8/26/2026
4.0.1431 121 8/12/2026
4.0.1430 121 7/28/2026
4.0.1429 110 7/28/2026
4.0.1428 119 7/27/2026
4.0.1427 125 7/18/2026
Loading failed

Updated Soenneker.Extensions.List to 4.0.988