In this example, the poster has overridden the get hash code method. I understand that this has been done in order to provide a better hash value for the returned object, to reduce the number of collisions, and therefore reduce the number of occasions it will be necessary to call Equals()
.
What i would like to know, is how this algorithm been calculated:
return 17 + 31 * CurrentState.GetHashCode() + 31 * Command.GetHashCode();
Is there a particular reason that the numbers in question were chosen? Could i have simply picked my own numbers to put into it?
Generally you should choose primes. This helps you to avoid getting the same hash-value for different input parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With