Sometimes, you need a different type of array conversion,
For example, the Int16 type of data that is read from the capture card needs to be stored in the database OLE object and converted into a byte type.
Here are two functions to complete the conversion.
private void Int16tobyte (int16[] arrInt16, int nint16count, ref byte[] Destbytearr)
{
High-byte in front, low-byte in the back
for (int i = 0; i < Nint16count; i++)
{
destbytearr[2 * i + 0] = Convert.tobyte ((arrint16[i] & 0xff00) >> 8);
destbytearr[2 * i + 1] = Convert.tobyte ((arrint16[i] & 0x00FF));
}
}
private void ByteToInt16 (byte[] arrbyte, int nbytecount, ref int16[] Destint16arr)
{
by two bytes An integer resolution, the previous byte as an integer high, the next byte as an integer low
for (int i = 0; i < NBYTECOUNT/2; i++)
{
Destint16arr[i] = convert.toint16 (arrbyte[2 * i + 0] << 8 + arrbyte[2 * i + 1]);
}
}
Conversion between C # byte array and Int16 array