https://github.com/soenneker/soenneker.extensions.enumerable
A collection of helpful enumerable extension methods
https://github.com/soenneker/soenneker.extensions.enumerable
csharp dotnet extension ienumerable
Last synced: about 1 month ago
JSON representation
A collection of helpful enumerable extension methods
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.extensions.enumerable
- Owner: soenneker
- License: mit
- Created: 2023-02-16T16:10:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-06-05T19:09:47.000Z (about 1 month ago)
- Last Synced: 2026-06-05T19:21:55.813Z (about 1 month ago)
- Topics: csharp, dotnet, extension, ienumerable
- Language: C#
- Homepage: https://soenneker.com
- Size: 785 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/Soenneker.Extensions.Enumerable/)
[](https://github.com/soenneker/soenneker.extensions.enumerable/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/Soenneker.Extensions.Enumerable/)
[](https://github.com/soenneker/soenneker.extensions.enumerable/actions/workflows/codeql.yml)
#  Soenneker.Extensions.Enumerable
### A collection of helpful enumerable extension methods
## Installation
```
dotnet add package Soenneker.Extensions.Enumerable
```
## Usage
### `IEnumerable` should have `IsNullOrEmpty()` too
```csharp
var populatedList = new List{"foo", "bar", "foo"};
populatedList.IsNullOrEmpty() // false
populatedList.Populated() // true
populatedList.None() // false
```
## One call checking for null and contains any elements
```csharp
List? nullList = null;
nullList.IsNullOrEmpty() // true
nullList.Populated() // false
```
### Duplicate handling
```csharp
var containsDuplicates = populatedList.ContainsDuplicates(); // true
var deduped = populatedList.RemoveDuplicates(); // {"foo", "bar"}
```
### Recursive flattening
```csharp
public class Node
{
public string Name {get; set;}
public List Children {get; set;}
}
void Example()
{
var node = new Node(){ Name = "Node1" };
node.Children = new List()
{
new Node()
{
Name = "Node2"
}
}
List? children = node.Children.ToFlattenedFromRecursive(c => c.Children);
// Results in flattened List:
// { Node1, Node2 }
}
```