Get size of struct in C#
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3361986/how-to-check-the-number-of-bytes-consumed-by-my-structure">How to check the number of bytes consumed by my Structure?</a>  </p>
</blockquote>



<p>I have a struct in the packed form of </p>

<pre><code>[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct test
{
  public int a;
  public uint16 b;
}
</code></pre>

<p>How do I get the size of the struct as the compiler stats that sizeof can only be used in unsafe context?</p>

<p>Thanks.</p>
