Comparing objects

前端 未结 5 1091

I have a class it contains some string members, some double members and some array objects.

I create two objects of this class, is there any simplest, efficient way

5条回答
  •  滥情空心
    2021-01-02 14:39

    The best answer is to implement IEquatable for your class - it may not be the answer you want to hear, but that's the best way to implement value equivalence in .NET.

    Another option would be computing a unique hash of all of the members of your class and then doing value comparisons against those, but that's even more work than writing a comparison function ;)

提交回复
热议问题