/// <summary> /// Method for pulling an unsigned short (2-byte) integer off the array. /// </summary> /// <param name="data">the byte array</param> /// <param name="offset">index where to begin pulling off the array</param> /// <returns>an unsigned short (2-byte) integer</returns> internal static UInt16 PopUnsignedShort(ref byte[] data, ref Int32 offset) { if (data.Length - offset < 2) { return(0); } UInt16 ret = NetConvert.NetworkToHostOrder(BitConverter.ToUInt16(data, offset)); offset += 2; return(ret); }
/// <summary> /// Method for pulling an unsigned integer from the byte array. /// </summary> /// <param name="data">the byte array</param> /// <param name="offset">index where to start pulling from the array</param> /// <returns>returns a 4-byte unsigned integer</returns> internal static UInt32 PopUnsignedInteger(ref byte[] data, ref Int32 offset) { if (data.Length - offset < 4) { return(0); } UInt32 ret = NetConvert.NetworkToHostOrder(BitConverter.ToUInt32(data, offset)); offset += 4; return(ret); }