CollectionHelper.cs 343 B

12345678910111213141516
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace FlowWorkEditDemo
  5. {
  6. static class CollectionHelper
  7. {
  8. public static void RemoveRange<T>(this ICollection<T> source, Func<T, bool> predicate)
  9. {
  10. var arr = source.Where(p => predicate(p)).ToArray();
  11. foreach (var t in arr)
  12. source.Remove(t);
  13. }
  14. }
  15. }