![]()
The size of the specified object in unmanaged code.
This method accepts an instance of a structure, which can be a reference type or a boxed value type. The layout must be sequential or explicit.
The size returned is the size of the unmanaged object. The unmanaged and managed sizes of an object can differ. For character types, the size is affected by the System.Runtime.InteropServices.CharSet value applied to that class.
You can use the Marshal.SizeOf(object) method to determine how much unmanaged memory to allocate using the erload:System.Runtime.InteropServices.Marshal.AllocHGlobal and Marshal.AllocCoTaskMem(int) methods.