我将两个字符串从 ASCII 十六进制转换为字节
byte[] address = new byte[2];
int fullAddress;
address[0] = Convert.ToByte(stringZero, 16);
address[1] = Convert.ToByte(stringOne, 16);
fullAddress = (address[0] << 0xFFFF);
fullAddress |= address[1];
这会在 的高半字节上产生错误的输出fullAddress
,低半字节总是正确的。这应该如何正确完成?
编辑:地址应该是 32 位值。例如,
StringZero = 0x01
StringOne = 0x02
fullAddress = 0x0102