public static void Main()
var tA = new MyType{ Id = 1 };
var tB = new MyType{ Id = 1 };
var tC = new MyType{ Id = 2 };
Console.WriteLine("tA == tA: " + (tA == tA));
Console.WriteLine("tA == tB: " + (tA == tB));
Console.WriteLine("tA == tC: " + (tA == tC));
Console.WriteLine("tA.Equals(tA): " + (tA.Equals(tA)));
Console.WriteLine("tA.Equals(tB): " + (tA.Equals(tB)));
Console.WriteLine("tA.Equals(tC): " + (tA.Equals(tC)));
Console.WriteLine("Equals(tA, tA): " + (Equals(tA, tA)));
Console.WriteLine("Equals(tA, tB): " + (Equals(tA, tB)));
Console.WriteLine("Equals(tA, tC): " + (Equals(tA, tC)));
public static bool operator ==(MyType A, MyType B)
public static bool operator !=(MyType A, MyType B)
public override bool Equals(object other)
var otherAsMyType = other as MyType;
if (otherAsMyType == null)
return Id == otherAsMyType.Id;
public override int GetHashCode()