add WhereNotNull

This commit is contained in:
Ryan Peters 2021-04-20 17:51:22 -04:00
parent d4cef72fd2
commit d12750e1c4
2 changed files with 14 additions and 1 deletions

View File

@ -9,8 +9,10 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Description>A bunch of common extensions</Description> <Description>A set of common utilities and extension methods for .NET.</Description>
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
<Version>21.4.20.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -255,6 +255,17 @@ namespace BinaryDad.Extensions
return list; return list;
} }
public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T> list)
{
foreach (var item in list)
{
if (item != null)
{
yield return item;
}
}
}
#endregion #endregion
#region ForEach #region ForEach