I have a situation where I have an Intptr, and I have a structure of my own which consists of 4 bytes. I want to read 4 bytes from the Intptr into this structure of mine. But i want to fill the 4 bytes in the structure individually. something like
mystruct obj = new mystruct().
obj.byte2 = “read fist byte from Myintptr”
obj.byte1 = “read next byte from MyIntptr”
is this possible ?
one of the ways could be that i read the whole thing into a byte array first using Marshal.copy(), and then do the second step of copying into obj.
But im curious i there is another way
Are you looking for something like this?