相关疑难解决方法(0)

对象等于 - 对于不重写等于的纯对象或引用类型的基本逻辑是什么?

我在读完这篇文章之后来到这里并且没有找到相关的答案 - 所以在你阅读整个问题之前,请不要将其标记为副本.

我一直在使用反射器并进行调查.Object.Equals我看到的是:

[__DynamicallyInvokable, TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public virtual bool Equals(object obj)
{
    return RuntimeHelpers.Equals(this, obj);
}
Run Code Online (Sandbox Code Playgroud)

而且RuntimeHelpers.Equals看起来是这样的:

// System.Runtime.CompilerServices.RuntimeHelpers
/// <summary>Determines whether the specified <see cref="T:System.Object" /> instances are considered equal.</summary>
/// <returns>true if the <paramref name="o1" /> parameter is the same instance as the <paramref name="o2" /> parameter, or if both are null, or if o1.Equals(o2) returns true; otherwise, false.</returns>
/// <param name="o1">The first object to …
Run Code Online (Sandbox Code Playgroud)

.net c#

11
推荐指数
2
解决办法
1012
查看次数

标签 统计

.net ×1

c# ×1