BitConverter.Get类型(new byte[] { 十六进制 })

解决方案 »

  1.   

    只举了部分例子。其中_byte本身就是8位有符号
    sbyte _byte = 0x45;            byte[] a = { 0x0B,0xB8 };
                Console.WriteLine(BitConverter.ToUInt16(a, 0));
                byte[] b = { 0xD1,0x00 };
                Console.WriteLine(BitConverter.ToInt16(b,0));
      

  2.   

    //两字节数组转为uint16
            public static UInt16 BytesToUint16Reverse(byte[] source, int start, int len)
            {
                byte[] b2 = new byte[2];
                UInt16 u16 = 0;
                try
                {
                    Array.Copy(source, start, b2, 0, len);
                    Array.Reverse(b2);
                    u16 = BitConverter.ToUInt16(b2, 0);
                }
                catch (Exception eu16)
                {
                    u16 = 0;
                }            return u16;
            }
      

  3.   


    楼上的兄弟,你都知道Uint16占用16位,两个字节,len参数没有意义 吧。