public static void Main()
int h1 = t.GetHashCode();
int h2 = t.GetHashCode();
Console.WriteLine("Objects with a single property");
Console.WriteLine("Are equal:" + (h1 == h2));
Console.WriteLine("Hash 1: " + h1);
Console.WriteLine("Hash 2: " + h2);
var multiPropertyHash1 = tmp2.GetHashCode();
var multiPropertyHash2 = tmp2.GetHashCode();
Console.WriteLine("Objects with multiple properties");
Console.WriteLine("Are equal:" + (multiPropertyHash1 == multiPropertyHash2));
Console.WriteLine("Hash 1: " + multiPropertyHash1);
Console.WriteLine("Hash 2: " + multiPropertyHash2);
var obj1Hash = obj1.GetHashCode();
var obj2Hash = obj2.GetHashCode();
Console.WriteLine("Different objects but with the same property values");
Console.WriteLine("Are equal:" + (obj1Hash == obj2Hash));
Console.WriteLine("Hash 1: " + obj1Hash);
Console.WriteLine("Hash 2: " + obj2Hash);
public string x{get;set;}
public override int GetHashCode()
return HashCode.Combine(x);
public string x {get; set; }
public int y { get; set; }
public override int GetHashCode()
return HashCode.Combine(x, y);