Hi, I'm having trouble converting a C++ structure to C#. This is the
definition of the C++ structure:
struct PLUGIN_PUBLISH_LIST
{
int nCount;
char sName[50][128];
char sValue[50][128];
char sHelp[50][256];
};
So basicly its a array of 50 strings for each, with a 128/256 character
array in each. So in C# I can use the MarshalAs attribute todo one or the
each (UnmanagedType.ByValTStr / UnmanagedType.ByValArray + SizeConst to
specify the size), but I cant work out how todo both. Can someone help me
work this out? Worst case scenario I guess I could just put 50 strings for
each in my structure but I really don't want to go there. Thanks in
advance. :)
Dan
chaor - 17 Jun 2004 12:18 GMT
you can treat the two dimension array as single dimension array.
like this:
[ StructLayout( LayoutKind.Sequential)]
public struct PLUGIN_PUBLISH_LIST
{
int nCount;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=6400)]
char[] sName;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=6400)]
char[] sValue;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=12800)]
char[] sHelp;
};