1

I have some kind of ULR object list like below

List<myUrl> urls = new List<myUrl>();

myUrl is a class that contains 4 field and all of them string.

in this list I want to find items does not contain another given list of values

List<myUrl> result = urls.FindAll(
   different_from_list_of_values condition;
);

how can I do that?

croxy
  • 4,082
  • 9
  • 28
  • 46
  • 1
    Possible duplicate of [Filter Linq EXCEPT on properties](http://stackoverflow.com/questions/15540891/filter-linq-except-on-properties) – usselite Jan 28 '16 at 12:36
  • This has been asked multiple times on SO. http://stackoverflow.com/questions/3944803/use-linq-to-get-items-in-one-list-that-are-not-in-another-list – SpaceSteak Jan 28 '16 at 12:36
  • try var filtered = basedEntityList.Where(i => !anotherList.Contains(i.Id)); Any or Contains methods works for this problem – Alper Tunga Arslan Jan 28 '16 at 12:40

1 Answers1

0

the best way should be topic, the idea is to override Equals method with your own logic, it have example for two fields class TwoDPoint. Then you just need to check this topic instead of p2.ID == p.ID => you would rather have p2.Equals(p)

Illia
  • 1
  • 1