111,098
社区成员




public Int16 HexToInt16(string p_strRaw)
{
int len = p_strRaw.Length;
byte[] TempArry = new byte[len / 2];
for (int i = 0; i < p_strRaw.Length / 2; i++)
{
TempArry[i] = Convert.ToByte(p_strRaw.Substring(i * 2, 2), 16);
}
return BitConverter.ToInt16(TempArry, 0);
}
Console.WriteLine(HexToInt16_("7B82"));
Console.WriteLine(HexToInt16("7B82"));
public static Int32 HexToInt16(string p_strRaw)
{
int len = p_strRaw.Length;
byte[] TempArry = new byte[len / 2];
for (int i = 0; i < p_strRaw.Length / 2; i++)
{
TempArry[i] = Convert.ToByte(p_strRaw.Substring(i * 2, 2), 16);
}
return BitConverter.ToInt16(TempArry, 0);
}
public static Int16 HexToInt16_(string p_strRaw)
{
var a = short.Parse(p_strRaw, NumberStyles.HexNumber);
var b = BitConverter.GetBytes(a);
return (Int16)(b[1] | b[0] << 8);
}
多得到 -32133