title: MemoryStream and constructing an array of bytes
body: <p>I am using a MemoryStream to construct an array of bytes i need to send to a server.I have thre questions:</p>
  
  <p>1) Is there a better way to construct an array of bytes than this ? </p>
  
  <p>2) Why this pice of code writes bogus in my memory stream ?</p>
  
  <pre><code>var
    serial : word;
    MS : TMemoryStream;
  const
    somebytes : array [0..1] of byte = ($72,$72);
  ...
  begin
        MS := TMemoryStream.Create();
        try
        MS.Write(somebytes[0],2);
        serial := $3E6C;
        MS.Write(serial,2);
        finally
        MS.Free;
  end;
  </code></pre>
  
  <p>Using the debugger i see that in the stream is added the value $6F32 instead of $3E6C.</p>
  
  <p>3) If i call </p>
  
  <pre><code>MS.Position := 2;
  </code></pre>
  
  <p>and then i access PByte(MS.Memory)^ why do i get the first byte in the stream instead of the third? </p>