我的一个朋友在 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 终止!)