public static void CallMe() { MyClass2 obj1 = new MyClass2("Shashank", "Delhi"); MyClass2 obj2 = new MyClass2("Shashank", "Gurgaon"); MyClass2 obj3 = new MyClass2("Shashank", "Gurgaon"); if (obj1.Equals(obj2)) { Console.WriteLine(true); } else { Console.WriteLine(false); } if (obj2.Equals(obj3)) { Console.WriteLine(true); } else { Console.WriteLine(false); } string s = null; string p = null; // if we check two null value using equals then null pointer exception will raise. see below code if (s.Equals(p)) { Console.WriteLine(true); } else { Console.WriteLine(false); } if (s == p) { Console.WriteLine(true); } else { Console.WriteLine(false); } //check if ToString() works on null string str = null; str = Convert.ToString(str); string ss = "hello"; string ts = "hello"; if (ss == ts) { Console.WriteLine(true); } else { Console.WriteLine(false); } }