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

ConvertByteArrayToUint() public static method

Convert a byte array to an unsigned integer. If the length of byte array is greater than 4, just convert the first 4 bytes.
public static ConvertByteArrayToUint ( byte bytes ) : uint
bytes byte The byte array to be converted
return uint
        public static uint ConvertByteArrayToUint(byte[] bytes)
        {
            uint uintValue = 0;
            int position = bytes.Length;

            if (position > 4)
            {
                position = 4;
            }

            for (int i = position - 1; i >= 0; i--)
            {
                uintValue <<= 8;
                uintValue += System.Convert.ToUInt32(bytes[i]);
            }

            return uintValue;
        }
Common