== vs. Object.Equals(object) in .NET

前端 未结 9 2260
无人及你
无人及你 2020-11-28 22:33

So, when I was a comparative novice to the novice I am right now, I used to think that these two things were syntactic sugar for each other, i.e. that using one over the oth

9条回答
  •  天涯浪人
    2020-11-28 23:28

    Two of the most often used types, String and Int32, implement both operator==() and Equals() as value equality (instead of reference equality). I think one can consider these two defining examples, so my conclusion is that both have identical meanings. If Microsoft states otherwise, I think they are intentionally causing confusion.

提交回复
热议问题