c# linq - get elements from array which do not exist in a different array

前端 未结 1 1830
猫巷女王i
猫巷女王i 2021-01-04 10:56

I have two arrays idxListResponse & _index both of which have the same structure.

Each of these arrays contains a number of elements with different properties on

相关标签:
1条回答
  • 2021-01-04 11:32

    Except is a good way of doing that:

    var items = source1.Except(source2);
    

    Would return all items in source1 except those in source2.

    Since your collections appear to be different types, you would do something like:

    source1.Except(source2.Select(s => /* selector here */))
    

    Or you could create your own implementation of IEqualityComparer and use that to compare the two different types.

    0 讨论(0)
提交回复
热议问题