GetHashCode()

  • Thread starter Thread starter Rahul Kumar
  • Start date Start date
R

Rahul Kumar

Could someone tell, which hashing algorithm is used in the
..Net's System.String.GetHashCode() call please?

--
Rahul Kumar
http://dotnetyogi.blogspot.com
This message is provided "AS IS" with no warranties, and confers no rights.
Any opinions or policies stated within it are my own and do not necessarily
constitute those of my employer.
 
I think the hash algorithm is private.
According to MS Developer Support, internal sources seem to indicate
that it is a relatively simple algorithm, but not one of the publicly
available ones.

Why do you need to know this? Be aware that the algorithm of
System.String.GetHashCode is private for a reason - whatever algorithm used
may be subject to change, so implementing logic tied to the algorithm used
at a given point in time is not recommendable.

In general, I found an excerpt stating the following about hash codes and
persistence.

"If you do need to persist out a hash code and ensure it doesn't change,
use your own IHashCodeProvider to implement your own hash function for each
data type you need to persist."

Tor Bådshaug
tor.badshaug (at) bekk.no.
 
Back
Top