public int x {get; private set;}
public int y {get; private set;}
public Point(int x, int y)
public override bool Equals(object obj)
return obj is Point p && x == p.x && y == p.y;
public override int GetHashCode()
public override String ToString()
return this.MemberwiseClone() as Point;
public static class App {
public static void Main()
Console.WriteLine("p1 : " + p1);
Console.WriteLine("p2 : " + p2);
Console.WriteLine("p3 : " + p3);
Console.WriteLine("p1 same as p2 : " + Object.ReferenceEquals(p1, p2));
Console.WriteLine("p1 égal p2 : " + Object.Equals(p1, p2));
Console.WriteLine("p1 égal p2 : " + p1.Equals(p2));
Console.WriteLine("p1 égal p3 : " + p1.Equals(p3));
Console.WriteLine("p1 égal null : " + p1.Equals(null));
Console.WriteLine("p1 == p2 : " + (p1 == p2) );
Console.WriteLine("p1 hashcode : " + p1.GetHashCode());
Console.WriteLine("p3 hashcode : " + p3.GetHashCode());