| Hi, Here is a stuct that I have to fill using a dll function : CODEstruct InfoRegister { public uint TargetIdBitField; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9) ] public char[] Label; public byte Mode; public byte Index; public byte CS; } The function signature : (Standart for ModBus communication protocol) CODEpublic MODBUS_ERROR ReadRegisters( ..., ushort[] pun16RegArray ); I would like to use it like : CODEInfoRegister ir = new InfoRegister(); ReadRegisters( ir ); But how can I convert my struct to a ushort[] reference ? And after that, how can I convert my ushort[] to a InfoRegister struct ? I can't use the UNSAFE mode for technical reasons. So I hope Marshal can do the trick ? Thanks for you help. |
Loading
Replies
Know the answer? Post it — somebody with the same question will find it here.