M
Michi Henning
From the Object.GetHashCode doc:
"The default implementation of GetHashCode does not guarantee uniqueness or
consistency; therefore, it must not be used as a unique object identifier
for hashing purposes."
I'm blown away by this statement.
Translation: the default implementation of GetHashCode() is unsuitable for hashing.
In particular, the doc also says:
"GetHashCode must always return the same value for a given instance
of the object."
It appears then that the default implementation of GetHashCode() does not meet
this requirement, given that the default implementation "does not guarantee
consistency."
What's happening here? Is the documentation really correct? It would mean
that System.Object.GetHashCode() is simply useless -- I'm finding that
hard to believe. On the other hand, if the documentation is correct, then
GetHashCode() should be abstract, no?
Thanks,
Michi.
"The default implementation of GetHashCode does not guarantee uniqueness or
consistency; therefore, it must not be used as a unique object identifier
for hashing purposes."
I'm blown away by this statement.
Translation: the default implementation of GetHashCode() is unsuitable for hashing.
In particular, the doc also says:
"GetHashCode must always return the same value for a given instance
of the object."
It appears then that the default implementation of GetHashCode() does not meet
this requirement, given that the default implementation "does not guarantee
consistency."
What's happening here? Is the documentation really correct? It would mean
that System.Object.GetHashCode() is simply useless -- I'm finding that
hard to believe. On the other hand, if the documentation is correct, then
GetHashCode() should be abstract, no?
Thanks,
Michi.