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

GetStringFromBinary() public static method

Get string from the byte array. If the byte array contains length, remove the first four byte
public static GetStringFromBinary ( byte bytes, bool isFirstTwoByteStoreLength ) : string
bytes byte The byte array contains string
isFirstTwoByteStoreLength bool Determine if the byte array contains length
return string
        public static string GetStringFromBinary(byte[] bytes, bool isFirstTwoByteStoreLength)
        {
            StringBuilder stringByteValue = new StringBuilder();
            foreach (byte by in bytes)
            {
                stringByteValue.Append(by.ToString("X2"));
            }

            if (isFirstTwoByteStoreLength)
            {
                // Del first four byte which store the byte array length
                stringByteValue.Remove(0, 4);
            }

            return stringByteValue.ToString();
        }
Common