Exemplo n.º 1
0
        public static UInt16 ToEndian(this UInt16 x, Endianness endian)
        {
            switch (endian)
            {
            case Endianness.LittleEndian: if (BitConverter.IsLittleEndian)
                {
                    return(x);
                }
                else
                {
                    return(x.SwapEndian());
                }

            case Endianness.BigEndian: if (BitConverter.IsLittleEndian)
                {
                    return(x.SwapEndian());
                }
                else
                {
                    return(x);
                }

            default: throw new Exception("Invalid Endianness");
            }
        }