title: Mapping Stream data to data structures in C#
body: <p>Is there a way of mapping data collected on a stream or array to a data structure or vice-versa?
  In C++ this would simply be a matter of casting a pointer to the stream as a data type I want to use (or vice-versa for the reverse)
  eg: in C++</p>
  
  <pre><code>Mystruct * pMyStrct = (Mystruct*)&amp;SomeDataStream;
  pMyStrct-&gt;Item1 = 25;
  
  int iReadData = pMyStrct-&gt;Item2;
  </code></pre>
  
  <p>obviously the C++ way is pretty unsafe unless you are sure of the quality of the stream data when reading incoming data, but for outgoing data is super quick and easy.</p>