Hi,
I must duplicate the behavior of .net string.GetHashCode in mono I used
reflector to get this code:
public static class HashCode {
                public static unsafe int GetCode(string value) {
                        fixed(char* str = ((char*)value)) {
                                char* chPtr = str;
                                int num = 0x15051505;
                                int num2 = num;
                                int* numPtr = (int*)chPtr;
                                for(int i = value.Length; i > 0; i -= 4) {
                                        num = (((num << 5) + num) + (num >> 
0x1b)) ^ numPtr[0];
                                        if(i <= 2) {
                                                break;
                                        }
                                        num2 = (((num2 << 5) + num2) + (num2 >> 
0x1b)) ^ numPtr[1];
                                        numPtr += 2;
                                }
                                return (num + (num2 * 0x5d588b65));
                        }
                }
        }
but it doesn't compile the error is 'Cannot convert type 'string' to
'char*''

Can somebody help me with this

Thanks

-- 
View this message in context: 
http://www.nabble.com/String.GetHashcode-tp24502903p24502903.html
Sent from the Mono - General mailing list archive at Nabble.com.

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to