title: How to assign a byte[] to a record
body: <p>In C++ it's done like that:</p>
  
  <pre><code>tPacket * packet = (tPacket *)data; //data is byte[] array; tPacket is a structure
  </code></pre>
  
  <p>In C#:</p>
  
  <pre><code>tPacket t = new tPacket();
  GCHandle pin = GCHandle.Alloc(data, GCHandleType.Pinned);
  t = (tPacket)Marshal.PtrToStructure(pin.AddrOfPinnedObject(), typeof(tPacket));
  pin.free();
  </code></pre>
  
  <p>Data is a byte array used as a receive buffer after a packet is received over TCP. That code puts data in an instance of tPacket (a structure) so I can access the structure later.</p>
  
  <p>How is it done in Delphi?</p>