2-dimensional array in struct

  • Thread starter Thread starter Richard Verzijl
  • Start date Start date
R

Richard Verzijl

Hi,
I want a 2-dimensional array in a struct.

In C it looks like:
struct struct1
{
int array1[4][2];
};

In C# I have a 1-dimensional array in a struct that looks like:
[StructLayout(LayoutKind.Sequential)]
public struct struct1
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst=8)] public int array1;
}

But I want a 2-dimensional array in a struct. How can I do this?


Richard
 
Richard,

In this case, what you have is the best solution. The reason for this
is that the marshaller can't figure out how to marshal the bytes across the
boundary, because of the number of dimensions. It would work for
one-dimensional arrays, but not multi-dimensional.



Hope this helps.
 
Back
Top