int a = 3; int b = 3; //string a = "abc", b = "abc"; //object a = 1; object b = 1; // object a = "abc"; object b = "abc"; if (a == b) { Console.WriteLine("true"); } else { Console.WriteLine("false"); } if (a.Equals(b)) { Console.WriteLine("true"); } else { Console.WriteLine("false"); } if (object.Equals(a, b)) { Console.WriteLine("true"); } else { Console.WriteLine("false"); } if (object.ReferenceEquals(a, b)) { Console.WriteLine("true"); } else { Console.WriteLine("false"); }
a
b
System.Object
ReferenceEquals
int
string
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)