if (obj == null)
 throw (new StackOverFlowException());

解决方案 »

  1.   

    这样还是不能使得Main函数调用的Console.WriteLine(nullPoint == null);
    通过呀.抛出的异常你又是怎么处理呢?
      

  2.   

    public static bool operator == (MyPoint p1, object p2)
    {                   if(p1==null&&p2!=null)
                                  return false;
    return p1.Equals(p2);
    }
      

  3.   

    or public override bool Equals(object obj)
    {
                                if(this==null&&obj!=null)
                                    return false;
    if (obj == null)
    return false;
    if(this.GetType() != obj.GetType())
    return false;
    MyPoint p = (MyPoint)obj;
    if (p.x == this.x && p.y == this.y)
    return true;
    else
    return false;
    }
      

  4.   

    这样会有StackOverFlowException异常抛出,因为在operator == 中使用了==
      

  5.   

    public static bool operator == (MyPoint p1, object p2)
    {
    object o1 = p1;
    object o2 = p2; if (o1 == o2)
    return true;
    else if (o1 == null || o2 == null)
    return false;

    return p1.Equals(p2);
    }
      

  6.   

    to realljx(至尊十三少): 帮忙测试一下上面的代码.不修改Main函数.只要运行成功就可以了.thanks!
      

  7.   

    是不是MyPoint类没有继承Object?