C# byte和10进制、16进制相互转换
2021-05-29 09:01
标签:replace ace htm get 16进制 class arp har http C# byte和10进制、16进制相互转换 标签:replace ace htm get 16进制 class arp har http 原文地址:https://www.cnblogs.com/lonelyxmas/p/11100219.htmlvar 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);