Best structure to use for interoperability

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have to pass an array containing a structure from a C# library to a C DLL.
Which is the best way to do it? Hashtable or ArrayList or anyother better
way.

Also, how do i marshal and then retreive the data at the C end.

Thanks
 
GeRmlc,

How is the array declared in the structure? If it is embedded in the
structure, then you can just declare it as an array and attach the MarshalAs
attribute to the field, specifying ByValArray as the UnmanagedType (and the
size as well).

If it is a pointer to an array, then you will have to marshal this
yourself, and manage the memory yourself.

Hope this helps.
 
Hi,

My structure is like this

public struct LMS
{
public long a;
public long b;
....etc.,
}

and i have to pass an array containing such structures to a calling C
program. The array will be a variable one, as the number of such structures
returned by the logic cannot be determined during design time.

Help.
Thanks!
 
Back
Top