How to convert this code:
MYCLASS ebt = new 开发者_Python百科MYCLASS();
ebt.cbStruct = Marshal.SizeOf(ebt);
into this:
MYCLASS ebt = new MYCLASS(cbStruct = Marshal.SizeOf('What comes here?'));
modify the MYCLASS ctor,
public MYCLASS()
{
cbStruct = Marshall.SizeOf(this);
}
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.
Use a MYCLASS
constructor that takes a cbStruct
parameter.
精彩评论