public override int GetHashCode() { unchecked { var hashCode = Offset.GetHashCode(); hashCode = hashCode * 31 + Length; if (Object != null) { hashCode = hashCode * 31 + Object.GetHashCode(); } return(hashCode); } }
public static void Equals(UIntPtr ptr1, object obj, bool expected) { if (obj is UIntPtr) { UIntPtr ptr2 = (UIntPtr)obj; Assert.Equal(expected, ptr1 == ptr2); Assert.Equal(!expected, ptr1 != ptr2); Assert.Equal(expected, ptr1.GetHashCode().Equals(ptr2.GetHashCode())); } Assert.Equal(expected, ptr1.Equals(obj)); Assert.Equal(ptr1.GetHashCode(), ptr1.GetHashCode()); }
public static void GetHashCodeRespectAllBits() { var ptr1 = new UIntPtr(0x123456FFFFFFFF); var ptr2 = new UIntPtr(0x654321FFFFFFFF); Assert.NotEqual(ptr1.GetHashCode(), ptr2.GetHashCode()); }
public override int GetHashCode() { return(_value.GetHashCode()); }