如何把byte[] 数组用10进制或16进制表示方式转为字符串
解决方案 »
- 关于抽象类,静态函数的两个问题,求教大神~~
- 后台生成的行和列的显示与隐藏
- 自己编写的C#软件 经Phoenix Protector加密 部分计算机间歇性键盘无响应
- 请教foreach循环问题,一个不规则数组{2,0,6,4,0,3,0,7}
- C#一个窗体获取另个窗体的控件
- C#如何在txt文本某个数据的后来添加字符呢?
- AllowSorting问题
- 怎样取得某个Class自身的实例名称?
- 怎么样打开新的Windows 窗体,并传参数?
- 如何在一个程序里,写一次处理错误的代码,就可以处理整个程序的全部错误,让它不会在运行时出错时退出?
- DrawString怎么知道字符串占据了几个像素?
- 急啊 !!!!!!!!!!! xml释放问题
十六进制:ToString("X")
byte[] bts = new byte[] { 9,10,11};string str10 = "";
for (int i = 0; i < bts.Length; i++)
{
str10 += bts[i].ToString("0");
}
string str16 = "";
for (int i = 0; i < bts.Length; i++)
{
str16 += bts[i].ToString("x");
}
byte [] bs = {1,2,3,4,5,6,7,8,9,10,11,12};
foreach (byte b in bs)
{
sb.AppendFormat("{0:X2}", b);
}
Console.WriteLine(sb);
=====
的方法可以
string str = BitConverter.ToString(buffer).Replace("-","");
foreach (byte b in data)
{
// 十进制
Console.WriteLine(b.ToString());
// 十六进制
Console.WriteLine(b.ToString("X"));
}