Esempio n. 1
0
        public static uint ToUint(byte[] bytes)
        {
            if (bytes.Length != 4)
            {
                throw new ArgumentException("Word can be constructed from four bytes only.");
            }

            uint word = 0;

            for (int i = 0; i < 4; i++)
            {
                word += bytes[i] * PowerCalculator.Two(8 * i);
            }

            return(word);
        }
Esempio n. 2
0
 public static byte GetByte(uint word, int byteIndex)
 {
     return((byte)(word / PowerCalculator.Two(8 * byteIndex) % 256));
 }