Why is String.GetHashCode() implemented differently in 32-bit and 64-bit versions of the CLR?

Viewed 2405

What are the technical reasons behind the difference between the 32-bit and 64-bit versions of string.GetHashCode()?

More importantly, why does the 64-bit version seem to terminate its algorithm when it encounters the NUL character? For example, the following expressions all return true when run under the 64-bit CLR.

"\0123456789".GetHashCode() == "\0987654321".GetHashCode()
"\0AAAAAAAAA".GetHashCode() == "\0BBBBBBBBB".GetHashCode()
"\0The".GetHashCode() == "\0Game".GetHashCode()

This behavior (bug?) manifested as a performance issue when we used such strings as keys in a Dictionary.

2 Answers
Related