How to convert this code:
MYCLASS ebt = new MYCLASS();
ebt.cbStruct = Marshal.SizeOf(ebt);
into this:
MYCLASS ebt = new MYCLASS(cbStruct = Marshal.SizeOf('What comes here?'));
How to convert this code:
MYCLASS ebt = new MYCLASS();
ebt.cbStruct = Marshal.SizeOf(ebt);
into this:
MYCLASS ebt = new MYCLASS(cbStruct = Marshal.SizeOf('What comes here?'));
Get the size of the type instead:
MYCLASS ebt = new MYCLASS { cbStruct = Marshal.SizeOf(typeof(MYCLASS)) };
Also note braces rather than parentheses to use initialiser syntax.
maybe you could make the cbStruct property a getter?
public object cbStruct { get { return Marshal.SizeOf(this); }}
modify the MYCLASS ctor,
public MYCLASS()
{
cbStruct = Marshall.SizeOf(this);
}