Difference between two lists

前端 未结 12 1316
无人共我
无人共我 2020-11-22 13:19

I Have two generic list filled with CustomsObjects.

I need to retrieve the difference between those two lists(Items who are in the first without the items in the sec

12条回答
  •  庸人自扰
    2020-11-22 13:38

    var list3 = list1.Where(x => !list2.Any(z => z.Id == x.Id)).ToList();
    

    Note: list3 will contain the items or objects that are not in both lists. Note: Its ToList() not toList()

提交回复
热议问题