'==' vs string.equals c# .net [duplicate]

2019-06-19 18:03发布

Possible Duplicate:
C#: String.Equals vs. ==

Hi to all.

Some time someone told me that you should never compare strings with == and that you should use string.equals(), but it refers to java.

¿What is the diference beteen == and string.equals in .NET c#?

8条回答
乱世女痞
2楼-- · 2019-06-19 18:47

no difference, it's just an operator overload. for strings it's internally the same thing. however, you don't want to get in a habit of using == for comparing objects and that's why it's not recommended to use it for strings as well.

查看更多
爷、活的狠高调
3楼-- · 2019-06-19 18:47

In C# there's no difference for strings.

查看更多
登录 后发表回答