string.Equals和object.ReferenceEquals的区别 [英] Difference in string.Equals and object.ReferenceEquals

查看:105
本文介绍了string.Equals和object.ReferenceEquals的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请解释string.Equals和object.ReferenceEquals

解决方案

中的差异说不好, String.Equals 比较字符串的值,即两个具有相同内容的字符串是相等的,而 ObjectReferenceEquals 比较它们的引用总是(它不能被覆盖)实例。

您可以在MSDN上找到更多信息:

String.Equals Method(System) [ ^ ]。

Object.ReferenceEquals Method(Object,Object)(System) [ ^ ]。

RTFM!



确定两个String对象是否具有相同的值。



确定指定的Object实例是否是同一个实例。


可以通过网络获取大量信息,你只需要google,让我帮你解决这个问题 string.Equals and object.ReferenceEquals - Google Search [ ^ ]


Please explain Difference in string.Equals and object.ReferenceEquals

解决方案

Poorly speaking, String.Equals compares strings by their values, that is two strings having the same content are equal, while ObjectReferenceEquals compare always (it cannot be overridden) instance by their references.
You may find more information at MSDN:
"String.Equals Method (System)"[^].
"Object.ReferenceEquals Method (Object, Object) (System)"[^].


RTFM!

Determines whether two String objects have the same value.


Determines whether the specified Object instances are the same instance.


Tons of information is avaiable over the net, you just need to google, let me help you even with that Difference in string.Equals and object.ReferenceEquals - Google Search[^]


这篇关于string.Equals和object.ReferenceEquals的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆