/// <summary> /// get 2 byte big endian unsigned int from byte array. /// </summary> /// <param name="Bytes"></param> /// <param name="Offset"></param> /// <returns></returns> public static ushort GetBigEndianUShort(this byte[] Bytes, int Offset) { if (Offset + 1 >= Bytes.Length) { throw new Exception("past end of byte array"); } var ip = IntParts.LoadBigEndianShort(Bytes, Offset); return(ip.UnsignedShortValue); }
/// <summary> /// get 3 byte big endian int from byte array. /// </summary> /// <param name="Bytes"></param> /// <param name="Offset"></param> /// <returns></returns> public static int GetBigEndianInt3(this byte[] Bytes, int Offset) { if (Offset + 2 >= Bytes.Length) { throw new Exception("past end of byte array"); } var ip = IntParts.LoadBigEndianInt3(Bytes, Offset); return(ip.IntValue); }
public static byte[] ToBigEndian(this short Value) { var buf = IntParts.ToBigEndianShort(Value); return(buf); }