What are you trying to accomplish? Object.GetHashCode() returns an int, so why wouldn't you store it as an int? But why would you want to do this?
|||Well I should have explained my question first. Sorry. I have a big long feild of string values that are unique. Insted of storing those string values I thouht that storing the Hascode will be faster. Since there will be gazillions of these values I just wanted to find out what would be the most optimized way to store them. The process to store values in the database will occur once a day but searching using this value would be a very common thing (over 14000 potential users). So would it be best to store it as int or perheps bytes or something else which is even faster :)Thanks for your help.|||Interesting idea. Well, I don't think GetHashCode is what you want. Reading fromhttp://msdn2.microsoft.com/en-us/library/system.object.gethashcode.aspx,
"The default implementation of theGetHashCode method does not guarantee unique return values for different objects. Furthermore, the .NET Framework does not guarantee the default implementation of theGetHashCode method, and the value it returns will be the same between different versions of the .NET Framework. Consequently, the default implementation of this method must not be used as a unique object identifier for hashing purposes."
There are other hashing mechanisms in .Nets crypto libraries that you should checkhttp://msdn2.microsoft.com/en-us/library/system.security.cryptography(VS.71).aspx. I don't know whether they have the same issues but one of the ideas of hashing is that even very large inputs return very small hashes
No comments:
Post a Comment