Why strings does not compare references?

后端 未结 5 1126
耶瑟儿~
耶瑟儿~ 2021-01-11 23:54

I know it is special case but why == between strings returns if their value equals and not when their reference equals. Does it have something to do with overlloading operat

5条回答
  •  甜味超标
    2021-01-12 00:15

    Yes. From .NET Reflector here is the equality operator overloading of String class:

    public static bool operator ==(string a, string b)
    {
        return Equals(a, b);
    }
    

提交回复
热议问题