SequenceEqual for specific properties

后端 未结 2 1517
鱼传尺愫
鱼传尺愫 2021-01-21 11:57

I would like to compare two lists of objects. The objects have four different properties. I need to compare only three of them as sequence (only three because one is always diff

相关标签:
2条回答
  • 2021-01-21 12:23

    You could use the SequenceEqual overload that allows you to pass in an IEqualityComparer<T> implementation that only includes the properties that you wish to compare.

    The example on that linked page is a good one.

    0 讨论(0)
  • 2021-01-21 12:35

    You can use the Enumerable.SequenceEqual overload that allows you to specify a custom IEqualityComparer - implement a custom one that only compares the three properties you are interested in.

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