Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public class MyReferenceType : IEquatable<MyReferenceType>, IComparable, IComparable<MyReferenceType>
  2. {
  3. public int Property1 { get; private set; }
  4. public int Property2 { get; private set; }
  5. public int Property3 { get; private set; }
  6. public int Property4 { get; private set; }
  7. public int Property5 { get; private set; }
  8. public int Property6 { get; private set; }
  9.  
  10. public MyReferenceType(int property1, int property2, int property3, int property4, int property5, int property6)
  11. {
  12. Property1 = property1;
  13. Property2 = property2;
  14. Property3 = property3;
  15. Property4 = property4;
  16. Property5 = property5;
  17. Property6 = property6;
  18. }
  19.  
  20. #region Equality
  21. public bool Equals(MyReferenceType obj)
  22. {
  23. if (ReferenceEquals(null, obj)) return false;
  24. if (ReferenceEquals(this, obj)) return true;
  25. return obj.Property2 == Property2;
  26. }
  27.  
  28. public override bool Equals(object obj)
  29. {
  30. if (ReferenceEquals(null, obj)) return false;
  31. if (ReferenceEquals(this, obj)) return true;
  32. if (obj.GetType() != typeof(MyReferenceType)) return false;
  33. return ((MyReferenceType)obj).Property1.Equals(Property1);
  34. }
  35.  
  36. public override int GetHashCode()
  37. {
  38. unchecked
  39. {
  40. return Property3.GetHashCode();
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement