Hi All,
Just a quick extension this time.
This one returns an IEnumerable<T> where all source items that fulfills a given conditions has been removed.
I've called it RemoveWhere.
Anyway - here you are:
public static IEnumerable<TSource> RemoveWhere<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> removeSelector)
{
List<TSource> result = new List<TSource>();
foreach (var s in source)
{
if (!removeSelector(s))
{
result.Add(s);
}
}
return result;
}
Can be used as:
WarehousePrinters = info.Printers.RemoveWhere(p => string.IsNullOrEmpty(p.PrinterID)).ToList();
As always feel to ask or comment.