日期:2014-05-17 浏览次数:20889 次
public static string binl2String(byte[] buffer) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < buffer.Length; i++) { builder.Append(buffer[i].ToString() + ","); } return builder.ToString().TrimEnd(','); } public static void Main() { byte[] bytes = { 0x01, 0x00, 0x01, 0x01, }; Console.WriteLine(binl2hex(bytes));//1,0,1,1 }
------解决方案--------------------
- -!、、
public string[] ByteToString(byte[] by){
string[] strArr = new string[by.Length];
for(int i = 0;i < by.Length;i++)
str[i] = by[i].ToString();
return strArr;
}
你确定 这是你想要的?、、、
------解决方案--------------------
我觉得你可以直接用string.formart来限制输出类型就好了
------解决方案--------------------
byte[] bytes = { 0x01, 0x00, 0x01, 0x01, };
Console.WriteLine(BitConverter.ToString(bytes, 0));
01-00-01-01
------解决方案--------------------
byte[] bytes = { 0x01, 0x00, 0x01, 0x01 }; int[] vals=new int[bytes.Length]; for (int i = 0; i < bytes.Length; i++) vals[i] = bytes[i]; Console.WriteLine(string.Join(",",vals));
------解决方案--------------------
string value = BitConverter.ToString(bytes);