Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pchc.DecodeMessage.GetUInt16 C# (CSharp) Method

GetUInt16() private static method

Parse ushort from bytes
private static GetUInt16 ( byte buffer, int &index, bool isBigEndian ) : ushort
buffer byte The buffer stores the value.
index int The index of start to parse
isBigEndian bool Order of bytes. If it's big endian, set it to true, else set it to false.
return ushort
        private static ushort GetUInt16(byte[] buffer, ref int index, bool isBigEndian)
        {
            ushort ushortReturn = 0;
            byte[] byteTemp = BitConverter.GetBytes(ushortReturn);

            Array.Copy(buffer, index, byteTemp, 0, byteTemp.Length);
            ReverseByFlag(isBigEndian, byteTemp);
            ushortReturn = BitConverter.ToUInt16(byteTemp, 0);
            index += byteTemp.Length;

            return ushortReturn;
        }