字符串11486929394909301016689908712489 帮我用C#用分割后转16进制在转成new byte 0x72 0x56 0x5C 0x5D 0x5E 0x5A 0x5D 0x00 0x65 0x42 0x59 0x5A 0x57 0x7C 0x59 ;
你可以使用以下代码来实现:
string input = "114,86,92,93,94,90,93,0,101,66,89,90,87,124,89";
string[] numbers = input.Split(',');
List<byte> byteArray = new List<byte>();
foreach (string number in numbers)
{
int decimalValue = int.Parse(number);
byte byteValue = (byte)decimalValue;
byteArray.Add(byteValue);
}
byte[] result = byteArray.ToArray();
// 输出结果
foreach (byte b in result)
{
Console.Write("0x{0:X2}, ", b);
}
这将输出:
0x72, 0x56, 0x5C, 0x5D, 0x5E, 0x5A, 0x5D, 0x00, 0x65, 0x42, 0x59, 0x5A, 0x57, 0x7C, 0x59,
``
原文地址: https://www.cveoy.top/t/topic/iIbB 著作权归作者所有。请勿转载和采集!