我需要将byte数组 显示出来,需要转成string,下面是代码
binchar是byte型数组
希望对那些刚学C#的朋友提供一些参考
//Mytext += ("{0:X}", binchar[currentAddr]) + " “;
//Mytext += (”{0:X}", binchar[currentAddr + 1] + " “);
//Mytext += (”{0:X}", binchar[currentAddr + 2] + " “); // 使用新方法
//Mytext += (”{0:X}", binchar[currentAddr + 3] + " “);
//Mytext += (”{0:X}", binchar[currentAddr + 4] + " ");
Mytext += binchar[currentAddr].ToString(“X2”) + " ";
Mytext += binchar[currentAddr + 1].ToString(“X2”) + " ";
Mytext += binchar[currentAddr + 2].ToString(“X2”) + " "; // 效果最好的方法
Mytext += binchar[currentAddr + 3].ToString(“X2”) + " ";
Mytext += binchar[currentAddr + 4].ToString(“X2”) + " ";