//overwrite object.equals() --- reference type realization
public override bool equals(object _obj)
{
if( _obj==null )
return false;//因为this不可能为null
if( ! (this.gettype()==_obj.gettype()) )
return false;//类型不相等也不相等
tree tmpobj=(tree)_obj;
//比较引用成员
if( !object.equals(this.key,tmpobj.key) )
return false;
//比较值类型成员
if( !this.degree.equals(tmpobj.degree) )
return false;
//if( !this.height.equals(tmpobj.height) )
//return false;
return true;
}
//在此重载 ==,!= 后, 在以后继承的类中不必实现了
public static bool operator==(tree _treea,tree _treeb)
{
return object.equals(_treea,_treeb);
}
public static bool operator!=(tree _treea,tree _treeb)
{
return !(_treea==_treeb);
}
#region icomparable 成员
public virtual int compareto(object obj)
{
// todo: 添加 tree.compareto 实现
return 0;
}
#endregion
}
}
转自:www.sinory.com
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器