阅读开源库源码,发现这两个方法,惭愧啊!真没看明白

        public static int TypeToInt(String type)
        {
            int result = (type[0] << 24) + (type[1] << 16) + (type[2] << 8) + type[3];
            return result;
        }

        public static String IntToType(int type)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append((char)((type >> 24) & 0xff));
            sb.Append((char)((type >> 16) & 0xff));
            sb.Append((char)((type >> 8) & 0xff));
            sb.Append((char)(type & 0xff));
            return sb.ToString();
        }

 

posted @ 2013-09-14 00:06  Adming  阅读(477)  评论(0编辑  收藏  举报