C# byte和10进制、16进制相互转换

var SRMP = new byte[4];
Array.Copy(Encoding.UTF8.GetBytes(1.ToString("x2")), SRMP, Encoding.UTF8.GetBytes(1.ToString("x2")).Length);
Array.Copy(Encoding.UTF8.GetBytes((j + 1).ToString("x2")), 0, SRMP, 1, Encoding.UTF8.GetBytes((j + 1).ToString()).Length);
 ushort leng = 1400;
byte[] a = new byte[2];
a[0] = (byte)(leng>>8);
a[1] = (byte)leng;
var ccc = BitConverter.ToString(a).Replace("-", "");
var dddd = Convert.ToInt32(ccc, 16); 
Array.Copy(a, 0, SRMP, 2, a.Length);

  

你可能感兴趣的:(C# byte和10进制、16进制相互转换)