String Equality operator == in c#

前端 未结 4 1044
心在旅途
心在旅途 2020-12-19 21:38

I have tried to peek into the code implemented for comparison operator in string class in C#. What found was this:

//THIS IS NOT WHAT I MEANT
public static          


        
4条回答
  •  梦毁少年i
    2020-12-19 22:24

    There is no String.Equals(object, object) method.
    You're seeing Object.Equals.

    The reason it doesn't recurse is that objA == objB calls the built-in object equality operator, not the custom string equality operator.
    (Operator overloads are resolved based on the compile-time type of the operands)

提交回复
热议问题