If you need your own implementation of Equals method of object what needs to be done

A) Overload Equals method
B) Override Equals method
C) Implements Equals method

Showing Answers 1 - 4 of 4 Answers

learnasp

  • Oct 11th, 2007
 

You also need to override the GetHashCode method if you override the equals method.

  • Override the GetHashCode method to allow a type to work correctly in a hash table.
  • Do not throw an exception in the implementation of an Equals method. Instead, return false for a null argument.
  • Follow the contract defined on the Object.Equals Method as follows:
    • x.Equals(x) returns true.
    • x.Equals(y) returns the same value as y.Equals(x).
    • (x.Equals(y) && y.Equals(z)) returns true if and only if x.Equals(z) returns true.
    • Successive invocations of x.Equals(y) return the same value as long as the objects referenced by x and y are not modified.
    • x.Equals(null) returns false.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions