Пример #1
0
 /// <summary>
 /// 字节数组中截取转成32位整型
 /// </summary>
 /// <param name="source"></param>
 /// <param name="start"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static int GetIntFromByteArray(byte[] source, int start = 0, DataFormat type = DataFormat.ABCD)
 {
     byte[] b = ByteArrayLib.Get4ByteArray(source, start, type);
     return(b == null?0: BitConverter.ToInt32(b, 0));
 }
Пример #2
0
 /// <summary>
 /// 将字节数组中某4个字节转换成Float类型
 /// </summary>
 /// <param name="source"></param>
 /// <param name="start"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static float GetFloatFromByteArray(byte[] source, int start = 0, DataFormat type = DataFormat.ABCD)
 {
     byte[] b = ByteArrayLib.Get4ByteArray(source, start, type);
     return(b == null ? 0.0f : BitConverter.ToSingle(b, 0));
 }