Where is == operator defined in Class “object”?

前端 未结 4 1154
渐次进展
渐次进展 2021-02-05 00:46

I searched the source code of FCL, and I got confused that string.Equals() uses Object.ReferenceEquals(), and Object.ReferenceEquals() use

4条回答
  •  無奈伤痛
    2021-02-05 01:04

    When there isn't an overloaded == operator (as here), the compiler emits a ceq instruction. There's no more C# code to look at at this point.

    Compares two values. If they are equal, the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack.

提交回复
热议问题