110,539
社区成员
发帖
与我相关
我的任务
分享
public abstract class BaseEntity
{
public virtual int Id { get; set; }
public override bool Equals(object obj)
{
return Equals(obj as BaseEntity);
}
public virtual bool Equals(BaseEntity other)
{
if (other == null || !(other is BaseEntity))
{
return false;
}
return (this == (BaseEntity)other);
}
public override int GetHashCode()
{
return Id.GetHashCode();
}
public static bool operator ==(BaseEntity x, BaseEntity y)
{
if ((object)x == null && (object)y == null)
{
return true;
}
if ((object)x == null || (object)y == null)
{
return false;
}
return x.Id == y.Id;
}
public static bool operator !=(BaseEntity x, BaseEntity y)
{
return !(x == y);
}
}
public class Child:BaseEntity
{
public Int32 F_Id { get; set; }
public String Name{ get; set; }
}
int _id;
public int F_Id { get { return _id; } set { _id = value; } }
public override int Id { get { return _id; } set { _id = value; } }
public int F_Id;
public override int Id { get { return F_Id; } set { F_Id = value; } }
base.Id = value;