gethashcode in A Sentence

    1

    This is an example of how ReSharper writes a Gethashcode() function for you:.

    0
    2

    If the Gethashcode() is equal, it is not necessary for them to be the same;

    0
    3

    Also often a object will NEVER be used in a collection that depends on Gethashcode().

    0
    4

    So the cost of implementing Gethashcode() is often not worth it, or it is not possible.

    0
    5

    It's actually very hard to implement Gethashcode() correctly because, in addition to the rules Marc already mentioned, the hash code should not change during the lifetime of an object.

    0
    6

    If someone puts your object in a collection that calls Gethashcode() and you have overrided Equals() without also making Gethashcode() behave in a correct way, that person may spend days tracking down the problem.

    0