Microsoft.Protocols.TestSuites.Common.Common.AddInt16LengthBeforeBinaryArray C# (CSharp) Method

AddInt16LengthBeforeBinaryArray() public static method

Add bytes length to the first two bytes of the new array, and append bytes to the new array
public static AddInt16LengthBeforeBinaryArray ( byte bytes ) : byte[]
bytes byte Original byte array
return byte[]
        public static byte[] AddInt16LengthBeforeBinaryArray(byte[] bytes)
        {
            int len = 0;
            if (bytes != null)
            {
                len = bytes.Length;
            }

            byte[] retValue = new byte[len + 2];
            retValue[0] = (byte)len;
            retValue[1] = (byte)(len >> 8);
            Array.Copy(bytes, 0, retValue, 2, len);

            return retValue;
        }
Common