string s1 = "hi";
string s2 = "hi";
bool x = (s1 == s2);
Console.WriteLine(bool.Parse(""+x)); //printed as true and my point of interest
x = s1.Equals(s2);
Console.WriteLine(bool.Parse("" + x));//printed as true
s1 = s2;
x = (s1 == s2);
Console.WriteLine(bool.Parse("" + x));//printed as true
x = s1.Equals(s2);
Console.WriteLine(bool.Parse("" + x));//printed as true
由于s1==s2
比较引用,它应该返回为 false。但我得到的输出是真的。我仅在字符串的情况下观察到这一点。当对其他类的对象执行此操作时,它正确地评估为 false。为什么在字符串中观察到这种异常行为?