title: Fast serialization/deserialization of structs
body: <p>I have huge amont of geographic data represented in simple object structure consisting only structs. All of my fields are of value type.</p>
  
  <pre><code>public struct Child
  {
     readonly float X;
     readonly float Y;
     readonly int myField;
  }
  
  public struct Parent
  {
     readonly int id;
     readonly int field1;
     readonly int field2;
     readonly Child[] children;
  }
  </code></pre>
  
  <p>The data is chunked up nicely to small portions of <code>Parent[]</code>-s. Each array contains a few thousands Parent instances. I have way too much data to keep all in memory, so I need to swap these chunks to disk back and forth. (One file would result approx. 2-300KB). </p>
  
  <p>What would be the most efficient way of serializing/deserializing the <code>Parent[]</code> to a <code>byte[]</code> for dumpint to disk and reading back? Concerning speed, <strong>I am particularly interested in fast deserialization</strong>, write speed is not that critical.</p>
  
  <p>Would simple <code>BinarySerializer</code> good enough?
  Or should I hack around with <a href="https://stackoverflow.com/questions/3563830/converting-system-decimal-to-system-guid"><code>StructLayout</code> (see accepted answer)</a>? I am not sure if that would work with array field of <code>Parent.children</code>.</p>
  
  <p>UPDATE: Response to comments - Yes, the objects are immutable (code updated) and indeed the <code>children</code> field is not value type. 300KB sounds not much but I have zillions of files like that, so speed does matter.</p>