title: Marshaling C arrays in C#
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9188523/marshaling-c-structures-in-c-sharp">Marshaling c structures in c#</a>  </p>
  </blockquote>
  
  
  
  <h1>Actual C structures:</h1>
  
  <pre><code>typedef struct procedure
  {
    char code[8];
  }procedure;
  
  typedef struct p45_cldxed24
  {
    procedure p45_cldxed[8];
  }p45_cldxed24;
  </code></pre>
  
  <p>What would be the equivalent C# structure for p45_cldxed24?  Specifically, how would you marshal the array?</p>
  
  <p><a href="https://stackoverflow.com/questions/9188523/marshaling-c-structures-in-c-sharp">check this out once</a></p>
  
  <h2>Is this correct?</h2>
  
  <pre><code>[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  struct p45_cldxed24
  {
      [MarshalAsAttribute(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct,SizeConst = 8,SizeParamIndex=0)]
      procedure[] p45_cldxed;
  }
  </code></pre>