C# String.Equals和运算符之间的无止境调用循环==

C# String.Equals和运算符之间的无止境调用循环==,c#,.net,string,C#,.net,String,我的一个朋友在String.cs中看到了两个方法的有趣源代码: [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static bool operator ==(string a, string b) { return Equals(a, b); } [TargetedPatchingOptOut("Performance critical to

我的一个朋友在String.cs中看到了两个方法的有趣源代码:

[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static bool operator ==(string a, string b)
{
    return Equals(a, b); 
}

[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static bool Equals(string a, string b)
{
    return ((a == b) || (((a != null) && (b != null)) && EqualsHelper(a, b)));
}

为什么它不会导致一个无止境的循环?(我们所有的程序都将被StackOverflowException终止!)

显然是这样,至少根据公认的答案是这样的


(在我得到一定数量的众议员万岁之前,我不能发表评论。)

你赢了我。当你的答案被张贴出来时,我也在试图插入我的第一个回答问题


听起来缺少的是对“object”的强制转换,这将迫使编译器使用object的Equals方法,并防止无限循环

看看@Shoaib:那么这只是dis-assembly工具中的一个bug?现在有一个无限循环的被接受的答案引用。编辑:哦,你的意思是在链接的帖子上:)哈哈,对了-这是对丹尼对这个问题评论的回答。具有讽刺意味的是,我最初对这个问题的评论本来是想作为一个答案的,但我认为这是微不足道的,并将其转化为一个评论。