title: Reading in a binary file containing an unknown quantity of structures (C#)
body: <p>Ok, so I currently have a binary file containing an unknown number of structs like this:</p>
  
  <pre><code>private struct sTestStruct
  {
      public int numberOne;
      public int numberTwo;
      public int[] numbers; // This is ALWAYS 128 ints long.
      public bool trueFalse;
  }
  </code></pre>
  
  <p>So far, I use the following to read all the structs into a List&lt;>:</p>
  
  <pre><code>List&lt;sTestStruct&gt; structList = new List&lt;sTestStruct&gt;();
  
  while (binReader.BaseStream.Position &lt; binReader.BaseStream.Length)
  {
      sTestStruct temp = new sTestStruct();
      temp.numberOne = binReader.ReadInt32();
      temp.numberTwo = binReader.ReadInt32();
      temp.numbers = new int[128];
      for (int i = 0; i &lt; temp.numbers.Length; i++)
      {
          temp.numbers[i] = binReader.ReadInt32();
      }
      temp.trueFalse = binReader.ReadBoolean();
  
      // Add to List&lt;&gt;
      structList.Add(temp);
  }
  </code></pre>
  
  <p>I don't really want to do this, as only one of the structs can be displayed to the user at once, so there is no point reading in more than one record at a time. So I thought that I could read in a specific record using something like:</p>
  
  <pre><code>fileStream.Seek(sizeof(sTestStruct) * index, SeekOrigin.Begin);
  </code></pre>
  
  <p>But it wont let me as it doesn't know the size of the sTestStruct, the structure wont let me predefine the array size, so how do I go about this??</p>