c# 的Hash码实现源码

 public int GetHashCode(string s)
    {
        int hash = 5381;
        int len = s.Length;

        for (int i = 0; i < len; i++)
        {
            int c = Convert.ToInt32(s[i]);
            hash = ((hash << 5) + hash) ^ c;
        }

        return hash;
    }

 

posted @ 2012-06-04 11:26  叮/当  阅读(318)  评论(1编辑  收藏  举报