views:

42

answers:

1

I have a set of strings that need to be load-balanced into 1 of 5 positions of a collection containing List<string>.

How can I take the string.Hash() and convert that into an Int that is somewhat evenly distributed?

I'm asking so I can figure out a solution for this ASP.NET issue.

+4  A: 

According to the documentation, the method returns a 32-bit signed integer. Why not just mod the value by 5? Assuming that the hashcode is a pseudo-evenly distributed number, the modulus values should also be evenly distributed.

Dave McClelland