欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-06-18 09:57:41
var SRMP = new byte[4]; Array.Copy(Encoding.UTF8.GetBytes(1.ToString("x2")), SRMP, Encoding.UTF8.GetBytes(1.ToString("x2")).Length); Array.Copy(Encodi... ......
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);