IEquatable 的Equals 代替 object 的Equals

  struct  Point2 : IEquatable<Point2>
    {
        public int X { get; set; }
        public int Y { get; set; }
       
        public bool Equals(Point2 obj)
        {

            return obj.X == this.X && obj.Y == this.Y;
        }

        public override int GetHashCode()
        {
            return X^Y;
        }
    }

 

posted @ 2016-08-16 09:58  zslm___  阅读(224)  评论(0编辑  收藏  举报