在字符串和整数之间转换 [英] convert between string and int

查看:78
本文介绍了在字符串和整数之间转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码:

I use this code:

//k[z] is my array to string
     string hex = "";
                      
                      foreach (char c in k[z])
                      {
                          int tmp = c;
                          hex += string.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));
}

在另一个地方
我希望十六进制"就像十六进制"恢复到第一个形状.

in another place
i want "hex" justlike "hex" comeback to first shape.

推荐答案

Slacker007的建议;

为什么不这样:hex + = string.Format("{0:x2}",tmp);
ad advice from Slacker007;

why not:hex += string.Format("{0:x2}", tmp);


这篇关于在字符串和整数之间转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆