LINQ - Find all items in one list that aren't in another list

前端 未结 3 1149
一个人的身影
一个人的身影 2020-12-28 12:01

I\'m stuck with a LINQ query (or any other efficient means of accomplishing the same thing). Can someone show me how I can select all the items in one list that are not pre

3条回答
  •  执念已碎
    2020-12-28 12:28

    Try using .Except extension method (docs):

    var result = list1.Except(list2);
    

    will give you all items in list1 that are not in list2.

提交回复
热议问题