I have an array of 4 unsigned int entries of the same value 255 I would like to convert them into a decimal value. Here is the code:
public static decimal BytesToDecimal(byte[] buffer, int offset = 0)
{
    var decimalBits = new int[4];
    decimalBits[0] = buffer[offset + 0] | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 16) | (buffer[offset + 3] << 24);
    decimalBits[1] = buffer[offset + 4] | (buffer[offset + 5] << 8) | (buffer[offset + 6] << 16) | (buffer[offset + 7] << 24);
    decimalBits[2] = buffer[offset + 8] | (buffer[offset + 9] << 8) | (buffer[offset + 10] << 16) | (buffer[offset + 11] << 24);
    decimalBits[3] = buffer[offset + 12] | (buffer[offset + 13] << 8) | (buffer[offset + 14] << 16) | (buffer[offset + 15] << 24);
    return new decimal(decimalBits);
 }
static void Main(string[] args)
{           
    decimal dd = BytesToDecimal(new byte[16] { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 });
     Console.WriteLine("{0}", dd.ToString());           
 }
I expect the result -1; however, the program throws the following exception.
Unhandled Exception: System.ArgumentException: Decimal byte array constructor requires an array of length four containing val id decimal bytes.
 
     
     
     
     
    