Difference between two lists

前端 未结 12 1282
无人共我
无人共我 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:43

    Since the Except extension method operates on two IEumerables, it seems to me that it will be a O(n^2) operation. If performance is an issue (if say your lists are large), I'd suggest creating a HashSet from list1 and use HashSet's ExceptWith method.

提交回复
热议问题