In C#, int is a signed 32-bit value, which gives a 4-byte array, so you could just write those bytes to the array like this:
void IntToArray(int val, byte[] array, int index)
{
uint temp = unchecked((uint)val);
for (int i = 0; i < 4; ++i)
{
array[index + i] = (byte)((temp >> i*8) & 0xff);
}
}
byte[] StructAToArray(A a)
{
byte[] array = new byte[8 + a.T.Length];
IntToArray(a.a, array, 0);
IntToArray(a.b, array, 4);
Array.Copy(a.T, 0, array, 8, a.T.Length);
return array;
}
Then you just have to do the corresponding conversion on the C++ side. :-)