Struct in c# communicating to unmanaged C DLL

  • Thread starter Thread starter sinclas
  • Start date Start date
S

sinclas

What is the equiviliant of the following struct written in C in C#? I
can't seem to get it. Any help would great! I have tried many
different ways, but none seem to work. any help/direction would be
great!


typedef struct abc
{
union
{
double num;
LPSTR str;
WORD bool1;
WORD err;
struct
{
struct abc far * lparray;
WORD rows;
WORD columns;
} array;
} val;
WORD xltype;
} abc, FAR * abc;
 
Look at the FieldOffsetAttribute documentation in MSDN.

You need to play around with that to basically simulate a union.

Also remember to set the size of the struct (along with LayoutKind=Explicit
and charset, if applicable) explicitly and not leave it to chance.

If you can do away with the union (if you're not using it to call some
unmanaged thing) then definitely do.
 
Back
Top