Please help me to convert an unmanaged structure pointer to byte[] in c#?
public struct struct1
{
public byte a;
public int b;
}
struct1 objstruct= new struct1();
struct1* ptrStruct=&objstruct;
ptrStruct->a=1;
ptrStruct->b=4;
how can i convert ptrStruct to byte[]?
Loading
VulpesPosted Sep 27, 2013, 6:11 AM
The following code does both. In the latter case, I've ignored the extra 3 bytes of padding which will bring the struct size up to 8 bytes: