sexta-feira, 24 de julho de 2015

LinqExtensions

using System;
using System.Collections.Generic;
using System.Linq;

namespace Lapuinka.Util
{
    public static class LinqExtensions
    {
        ///
        /// Remove all items that match the especified filter.
        ///
        /// List type.
        /// The current list.
        /// The filter.
        public static IEnumerable RemoveAll(this IList list, Funcbool> filter)
        {
            var items = list.Where(filter).ToArray();

            foreach (var item in items)
            {
                list.Remove(item);
            }

            return items;
        }
    }
}


Postar um comentário