Converting BYTE array to INT

As the name suggests, an Int32 is 32 bits, or 4 bytes, so if you want to convert a byte array to an Int32, it needs to have a length of at least 4, (or more precisely, it needs to have least 4 bytes after the start position).

If all you have is two bytes, maybe you meant to use ToInt16?


An Int32 is composed of 4 bytes but the array only has 2. One way to work around this is to first convert to Int16 and then to Int32

Console.WriteLine((Int32)(BitConverter.ToInt16(array, 0)));

Note that in this specific usage converting to Int32 from Int16 doesn't change anything because the numbers print the same.