G
Guest
I had a scenario here.
[StructLayout(LayoutKind.Sequential)]
public struct StructA
{
public byte avalue;
public byte bvalue;
public IntPtr InData;
public StructA(byte a, byte b)
{
this.avalue = a;
this.bvalue = b;
this.InData = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(System.Byte)));
}
}
....
byte[] someByteArray = new byte[5] {0x00, 0x01, 0x02, 0x03, 0x04};
StructA myStructA = new StructA(0,0);
myStructA.avalue = 0x09;
myStructA.bvalue = 0xf0;
Marshal.Copy(someByteArray, 0, myStructA.InData,
Marshal.SizeOf(typeof(System.Byte)));
The question is i assume that myStructA, will store the address and where it
points the byte array. Okay, just assume
1)
i want to see what is myStructA.InData is pointing at with Visual Studio .NET
and
2)
how do i write c# codes to do the same thing?
Any help please? Thanks.
[StructLayout(LayoutKind.Sequential)]
public struct StructA
{
public byte avalue;
public byte bvalue;
public IntPtr InData;
public StructA(byte a, byte b)
{
this.avalue = a;
this.bvalue = b;
this.InData = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(System.Byte)));
}
}
....
byte[] someByteArray = new byte[5] {0x00, 0x01, 0x02, 0x03, 0x04};
StructA myStructA = new StructA(0,0);
myStructA.avalue = 0x09;
myStructA.bvalue = 0xf0;
Marshal.Copy(someByteArray, 0, myStructA.InData,
Marshal.SizeOf(typeof(System.Byte)));
The question is i assume that myStructA, will store the address and where it
points the byte array. Okay, just assume
1)
i want to see what is myStructA.InData is pointing at with Visual Studio .NET
and
2)
how do i write c# codes to do the same thing?
Any help please? Thanks.