I have an array of Int32 represented by Byte array (every 4 bytes are 1 Int32) and i want to convert them to Int32 array (with length of Byte.length/4). here is example of what i want:
//byte[] buffer;
for (int i=0; i<buffer.Length; i+=4)
{
Int32 temp0 = BitConverter.ToInt32(buffer, i);
temp0 += 10;
byte[] temp1 = BitConverter.GetBytes(temp0);
for (int j=0;j<4;j++)
{
buffer[i + j] = temp1[j];
}
}
But I don't want to copy them, I just want to be able to tell the compiler that it is Int32 array and not a byte array (in order to later manipulation).
I looked at this How to Convert a byte array into an int array but it convert every byte into Int32 and I want to convert every 4 bytes into Int32. I also would like to this without copy it into another array for performance.
(we can assume that hardware is the endianness native, little endian system for little endian representation).