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?
obj.byte1 = System.Runtime.InteropServices.Marshal.ReadByte(ip, 0);
obj.byte2 = System.Runtime.InteropServices.Marshal.ReadByte(ip, 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With