日期:2014-05-17 浏览次数:20910 次
string[] source = { "01", "10", "50", "100", "1000", "5000" }; byte[] result = source.Select(x => int.Parse(x)).SelectManay(x => x < 256 ? new byte[] { (byte)x } : new byte[] { (byte)(x / 256), (byte)(x % 256) }).ToArray();
------解决方案--------------------
String[] x = { "01", "10", "50", "100", "1000", "5000", int.MaxValue.ToString() }; String xxx = ""; foreach (String xx in x) { String _x = int.Parse(xx).ToString("X"); _x = _x.Length % 2 != 0 ? "0" + _x : _x; for (int i = 0; i < _x.Length / 2;i++ ) xxx += "0x" + _x.Substring(i,2) + ","; } xxx = xxx.TrimEnd(','); String[] b = xxx.Split(',');; foreach(string y in b) MessageBox.Show(y + "\r\n");