Guest User

Untitled

a guest
Jan 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. using System.Collections.Generic;
  2.  
  3. public static class ListExtension
  4. {
  5. public static bool Remove<T>(this List<T> list, T item, IEqualityComparer<T> compare)
  6. {
  7. bool hasEntry = false;
  8. foreach (T entry in list)
  9. {
  10. if (!compare.Equals(item, entry))
  11. {
  12. continue;
  13. }
  14.  
  15. hasEntry = true;
  16. list.Remove(entry);
  17. break;
  18. }
  19.  
  20. return hasEntry;
  21. }
  22. }
Add Comment
Please, Sign In to add comment