private UInt16 ParseUInt16(byte[] data, ref int index, bool isBigEndian) { // Read 2 bytes byte[] bytes = GetBytes(data, ref index, sizeof(UInt16)); // Big Endian format requires reversed byte order if (isBigEndian) { Array.Reverse(bytes, 0, sizeof(UInt16)); } // Convert return BitConverter.ToUInt16(bytes, 0); }