110,572
社区成员
发帖
与我相关
我的任务
分享
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
RuntimeType type = (RuntimeType) base.GetType();
RuntimeType type2 = (RuntimeType) obj.GetType();
if (type2 != type)
{
return false;
}
object a = this;
if (CanCompareBits(this))
{
return FastEqualsCheck(a, obj);
}
FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
for (int i = 0; i < fields.Length; i++)
{
object obj3 = ((RtFieldInfo) fields[i]).InternalGetValue(a, false);
object obj4 = ((RtFieldInfo) fields[i]).InternalGetValue(obj, false);
if (obj3 == null)
{
if (obj4 != null)
{
return false;
}
}
else if (!obj3.Equals(obj4))
{
return false;
}
}
return true;
}
public override int GetHashCode()
{
FieldInfo[] fields = GetType().GetFields(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance);
int posn;
Object value;
for (posn = 0; posn < fields.Length; ++posn)
{
value = fields[posn].GetValue(this);
if (value != null) return value.GetHashCode();
}
return GetType().GetHashCode();
}
public override bool Equals(Object obj)
{
if (obj == null) return false;
else
{
Type type = GetType();
if (type != obj.GetType()) return false;
FieldInfo[] fields = type.GetFields(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance);
int posn;
Object value1,value2;
for (posn = 0; posn < fields.Length; ++posn)
{
value1 = fields[posn].GetValue(this);
value2 = fields[posn].GetValue(obj);
if (value1 == null)
{
if (value2 != null) return false;
}
else if (value2 == null)
{
return false;
}
else if (!value1.Equals(value2))
{
return false;
}
}
return true;
}
}