C# what is the size of unmanaged object?
<p>Read definition of <code>Marshal.SizeOf().</code> It says this: <code>The size returned is the size of the unmanaged object. The unmanaged and managed sizes of an object can differ.</code> Is that means Marshal.SizeOf will return you the definition size but not the actual memeory allocated size because there are may have some padding for alignment?</p>

<p>For example:</p>

<pre><code>struct MyStruct
{
   char c;
}
</code></pre>

<p>The size will be 1 byte for unmanaged object (unmanaged size) if I use <code>Marshal.SizeOf()</code> but may be 2 or 4 bytes for managed object (managed size) if I use <code>sizeof(</code>). Am I right?</p>
