自定义条件判断两对象相等Equals的方法
自定义两对象是否相等方法,必须用到GetHashCode方法,如
public class AirspaceCompareByUUID : IEqualityComparer<AIRSPACE_TS>
{
public bool Equals(AIRSPACE_TS x, AIRSPACE_TS y)
{
if (x == null || y == null)
return false;
if (x.AIRSPACE_UUID == y.AIRSPACE_UUID)
return true;
else
return false;
}
public int GetHashCode(AIRSPACE_TS obj)
{
if (obj == null)
return 0;
else
return obj.AIRSPACE_UUID.GetHashCode();
}
}