rspec/rules/S1206/csharp/rule.adoc

10 lines
516 B
Plaintext
Raw Normal View History

2020-12-23 14:59:06 +01:00
There is a contract between ``Equals(object)`` and ``GetHashCode()``: If two objects are equal according to the ``Equals(object)`` method, then calling ``GetHashCode()`` on each of them must yield the same result. If this is not the case, many collections won't handle class instances correctly.
2020-06-30 12:47:33 +02:00
2020-12-23 14:59:06 +01:00
In order to comply with the contract, ``Equals(object)`` and ``GetHashCode()`` should be either both inherited, or both overridden.
2020-06-30 12:47:33 +02:00
include::../noncompliant.adoc[]
include::../compliant.adoc[]
include::../see.adoc[]