When can a == b be false and a.Equals(b) true?

后端 未结 7 1772
离开以前
离开以前 2021-02-01 04:59

I ran into this situation today. I have an object which I\'m testing for equality; the Create() method returns a subclass implementation of MyObject.

MyObject         


        
7条回答
  •  既然无缘
    2021-02-01 05:24

    a == b checks if they reference the same object.

    a.Equals(b) compares the contents.

    This is a link to a Jon Skeet article from 2004 that explains it better.

提交回复
热议问题