G
Guest
I get the following error messages when compiling my code:
The best overloaded method match for 'ByteArrayToStructure(byte[], ref
object)' has some invalid arguments Form1.cs
Argument '2': cannot convert from 'ref RESPONSE_STRUCT' to 'ref object'
Form1.cs
My code is as follows:
public struct RESPONSE_STRUCT
{
public byte Format;
public short sNumBytes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public byte[] szDateTime;
}
private static void ByteArrayToStructure(byte[] bytearray, ref object obj)
{
//code here
}
RESPONSE_STRUCT pResponseStruct = new RESPONSE_STRUCT();
byte[] pBuffer = new byte[Marshal.SizeOf(pResponseStruct)];
ByteArrayToStructure(pBuffer, ref pResponseStruct); << Error is because
something is wrong here
Thanks for any help.
Terry
The best overloaded method match for 'ByteArrayToStructure(byte[], ref
object)' has some invalid arguments Form1.cs
Argument '2': cannot convert from 'ref RESPONSE_STRUCT' to 'ref object'
Form1.cs
My code is as follows:
public struct RESPONSE_STRUCT
{
public byte Format;
public short sNumBytes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public byte[] szDateTime;
}
private static void ByteArrayToStructure(byte[] bytearray, ref object obj)
{
//code here
}
RESPONSE_STRUCT pResponseStruct = new RESPONSE_STRUCT();
byte[] pBuffer = new byte[Marshal.SizeOf(pResponseStruct)];
ByteArrayToStructure(pBuffer, ref pResponseStruct); << Error is because
something is wrong here
Thanks for any help.
Terry