C# Filter Extension Method

April 24, 2024

C# & .NET

C# Filter Extension Method

Thuta Sann

Thuta Sann

This is the C# Filter extension Method Sample.


Share This Snippet To :

C# Filter Extension Method

namespace ExtensionsSample { public static class Extension { /// <summary> /// Extension Filtered Method /// </summary> /// <typeparam name="T"></typeparam> /// <param name="records"></param> /// <param name="func"></param> /// <returns></returns> public static List<T> Filter<T>(this List<T> records, Func<T, bool> func) { List<T> filteredList = new(); foreach (T record in records) { if (func(record)) { filteredList.Add(record); } } return filteredList; } } }

Cookie

I baked some cookies that you have to accept, if you want to enjoy my portfolio.
In order to gather information and make improvements, I should use some third-party cookies too, Can I?