code_junkie

Deleting items from one collection in another collection

Nov 11th, 2011
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. listB.RemoveAll(listA.Contains);
  2.  
  3.  
  4. foreach (string str in listA.Intersect(listB))
  5. listB.Remove(str);
  6.  
  7. foreach(TypeA objectA in listA){
  8. listB.RemoveAll(objectB => objectB.Id == objectA.Id);
  9. }
  10.  
  11. for (item i: LISTA) {
  12. removeItem(i, LISTB);
  13. }
  14.  
  15.  
  16. method removeItem(Item, List) {
  17. for (Item i: List) {
  18. if (Item == i)
  19. List.removeItem(i);
  20. }
  21. }
  22.  
  23. foreach Object o in ListA
  24. If ListB.contains(o)
  25. ListB.remove(o)
Add Comment
Please, Sign In to add comment