title: C# array within a struct
body: <p>Want to do this:
  (EDIT:  bad sample code, ignore and skip below)</p>
  
  <pre><code>struct RECORD {
      char[] name = new char[16];
      int dt1;
  }
  struct BLOCK {
      char[] version = new char[4];
      int  field1;
      int  field2;
      RECORD[] records = new RECORD[15];
      char[] filler1 = new char[24];
  }
  </code></pre>
  
  <p>But being unable to declare array sizes in struct, how do I reconfigure this?</p>
  
  <p>EDIT:  The reason for the layout is I'm using BinaryReader to read a file written with C structs.  Using BinaryReader, and a C# struct union (FieldOffset(0)), I'm wanting to load the header as a byte array, then read it as it was intended originally.</p>
  
  <pre><code>[StructLayout(LayoutKind.Sequential)]
  unsafe struct headerLayout
  {
      [FieldOffset(0)]
      char[] version = new char[4];
      int fileOsn;
      int fileDsn;
      // and other fields, some with arrays of simple types
  }
  
  [StructLayout(LayoutKind.Explicit)]
  struct headerUnion                  // 2048 bytes in header
  {
      [FieldOffset(0)]
      public byte[] headerBytes;      // for BinaryReader
      [FieldOffset(0)]
      public headerLayout header;     // for field recognition
  }
  </code></pre>