首页 新闻 搜索 专区 学院

java 代码转C#代码

0
悬赏园豆:10 [已关闭问题] 解决于 2016-03-21 14:40

来信大神,帮忙帮下面的JAVA代码转成c#代码

 

private static final String HEX_CHARS = "0123456789abcdef";

public static String toHexString(byte[] b) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < b.length; i++) {
sb.append(HexUtil.HEX_CHARS.charAt(b[i] >>> 4 & 0x0F));
sb.append(HexUtil.HEX_CHARS.charAt(b[i] & 0x0F));
}
return sb.toString();
}

beggar_的主页 beggar_ | 初学一级 | 园豆:23
提问于:2016-03-21 09:29
< >
分享
其他回答(1)
0
  private const String HEX_CHARS = "0123456789abcdef";

        public static String toHexString(byte[] b) {
           StringBuilder  sb = new StringBuilder();
            for (int i = 0; i < b.Length; i++) {
            sb.Append(HEX_CHARS.ElementAt(b[i] = 4 & 0x0F));
            sb.Append(HEX_CHARS.ElementAt(b[i] = 0x0F));
            }
            return sb.ToString();
        }

最好是找一下  HexUtil 这个C#下的引用 

 

http://www.thinksaas.cn/group/topic/397013/

收获园豆:2
多罗贝勒 | 园豆:16 (初学一级) | 2016-03-21 09:48
0
 private const string HEX_CHARS = "0123456789abcdef";

        public static string toHexString(byte[] b)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < b.Length; i++)
            {
                sb.Append(HEX_CHARS.Substring((b[i] / (int)(Math.Pow(2, 4))) & 0x0F, 1));
                sb.Append(HEX_CHARS.Substring(b[i] & 0x0F, 1));
            }
            return sb.ToString();
        }

试试看

收获园豆:3
MrNice | 园豆:3025 (老鸟四级) | 2016-03-21 09:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册