title: Marshal.SizeOf on a struct containing guid gives extra bytes
body: <p>I have several structs that have sequential layout:</p>
  
  <pre><code>struct S1
  {
    Guid id;
  }
  
  struct S2 
  {
    Guid id;
    short s;
  }
  
  struct S3 
  {
    Guid id;
    short s;
    short t;
  }
  </code></pre>
  
  <p>Calling <code>Marshal.SizeOf</code> on above struct types,
  I got:</p>
  
  <pre><code>Size:
  S1 = 16, as expected.
  S2 = 20, copied an instance to a byte array, it only occupies first 18 bytes.
  S3 = 20.
  </code></pre>
  
  <p>My question is that why the size of S2 is 20 but not 18. And this problem only comes up when <code>Guid</code> is in the struct. </p>
  
  <p>Sorry can't find any useful info from msdn. I know <code>Marshal.SizeOf</code> gives the size of space the type will occupy in the memory, but I want to know why it deserves 2 extra bytes to make the size a multiple of 4.</p>
  
  <p>And how can I avoid this "problem"?</p>
  
  <p>Thanks a lot!</p>