From d12750e1c4fe3cfcd9e7df6754faeea47771c901 Mon Sep 17 00:00:00 2001 From: binarydad Date: Tue, 20 Apr 2021 17:51:22 -0400 Subject: [PATCH] add WhereNotNull --- BinaryDad.Extensions/BinaryDad.Extensions.csproj | 4 +++- .../Extensions/CollectionExtensions.cs | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/BinaryDad.Extensions/BinaryDad.Extensions.csproj b/BinaryDad.Extensions/BinaryDad.Extensions.csproj index 1a6ded9..33e62a3 100644 --- a/BinaryDad.Extensions/BinaryDad.Extensions.csproj +++ b/BinaryDad.Extensions/BinaryDad.Extensions.csproj @@ -9,8 +9,10 @@ netstandard2.0 - A bunch of common extensions + A set of common utilities and extension methods for .NET. 7.3 + 21.4.20.1 + true diff --git a/BinaryDad.Extensions/Extensions/CollectionExtensions.cs b/BinaryDad.Extensions/Extensions/CollectionExtensions.cs index 024b6be..af23fb5 100644 --- a/BinaryDad.Extensions/Extensions/CollectionExtensions.cs +++ b/BinaryDad.Extensions/Extensions/CollectionExtensions.cs @@ -255,6 +255,17 @@ namespace BinaryDad.Extensions return list; } + public static IEnumerable WhereNotNull(this IEnumerable list) + { + foreach (var item in list) + { + if (item != null) + { + yield return item; + } + } + } + #endregion #region ForEach