CollectionHelper.cs 355 B

123456789101112131415161718
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace Flowchart
  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. {
  13. source.Remove(t);
  14. }
  15. }
  16. }
  17. }