==比较的是引用,Equals()比较的是值
string a = new string(new char[] { 'a', 'b', 'c' });
string b = new string(new char[] { 'a', 'b', 'c' });
object f = a;
object h = b;
bool z = (f == h);
bool e = f.Equals(h);
Console.WriteLine("f的值是{0},h的值是{1};\n用==比较结果:{2},用Equals比较结果:{3}", f, h,z,e);
Console.Read(); |