把txtbox里的数据存入byte数组
例如 txtbox里内容为“01ac0c01”
每两位的存入byte数组。得到的为byte【】a={01,ac,0c,01};
该如何完成,谢谢
[解决办法]
- C# code
string ss = "01ac0c01"; int len = ss.Length / 2; byte[] bs = new byte[len]; int j = 0; for (int i = 0; i < ss.Length; i += 2) { string str = ss.Substring(i, 2); bs[j] = (byte)int.Parse(str, System.Globalization.NumberStyles.HexNumber); j++; }