0

I am attempting to compare a bitwise clone object to its parent to check for changes using:

If Not objCP.Equals(objCPClone) Then
    'do something
End If

and it always compares as not equal even immediately after creating the clone.

How should they be compared to check for changes?

Joey
  • 344,408
  • 85
  • 689
  • 683
Rick H.
  • 165
  • 1
  • 10

1 Answers1

2

Override the Equals method (and GetHashCode along the way) to actually check for equality of all necessary fields or properties. The default implementation (inherited from Object) just checks whether the references are the same (i.e. whether they are pointing to the same object).

Joey
  • 344,408
  • 85
  • 689
  • 683