Mike,
You are going to have to work around it, unfortunately. There is no
guarantee that the hashcode is going to be unique across different versions
of the framework, or even across calls to GetHashCode across different
invocations of the program.
The default implementation of GetHashCode for object just returns a
counter to the object reference. This will always be different across
invocations of any program for any type that doesn't override GetHashCode.
If you need a hash that is predictable, then you have to go with a
well-known algorithm. You should look in the System.Security.Cryptography
namespace, and use the MD5 or SHA1 algorithm for hashing your data. This
will give you predictable results every time.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Mike9900 said:
Hello,
I am wondering why GetHashCode() for the string is using two differemt
algorithms in .NET Framework 1.1 and 2.
This is creating a big problem, because we relied on this hashcode as
unique. How can we fix this problem?