title: C#, read structures from binary file
body: <p>I want to read structures from binary.
  In C++ I would do it like this:</p>
  
  <pre><code>stream.read((char*)&amp;someStruct, sizeof(someStruct));
  </code></pre>
  
  <p>Is there a similar way in C#? The BinaryReader only works for built-in types. In .NET 4 there is a MemoryMappedViewAccessor. It provides methods like <code>Read&lt;T&gt;</code> which seems to be what I want, except that I manually have to keep track of where in the file I want to read.
  Is there a better way?</p>