Int3232 bits or four bytes are required. Your array contains only two bytes, which means you cannot convert it to Int32.
You can convert it to Int16
int length = BitConverter.ToInt16(bytes_length, 0);
or expand two bytes to an array before conversion Int32.
Alternatively, you can skip copying altogether:
int length = BitConverter.ToInt16(data, Place_of_length);
source
share