C #
Out
Modification, corresponding to the C ++/CLI
[Outattribute] T %
Initial code
(C ++/CLI ):
Void XXX (intptr % handle );
(C #):
Intptr handle;
XXX (Out handle );
At the beginning, C # Always prompts when calling C ++/CLI functions because there is no [outattribute ].
Error cs1502: the overload method that best matches "XXX (ref intptr)" has some invalid parameters.
Error cs1620: parameter 2 must be passed with the keyword "Ref"
Therefore, modify the C # code
Intptr handle;
XXX (ref handle );
Prompt again
Error cs0165: the unspecified local variable "handle" is used"
Sui
Intptr handle = intptr. zero;
XXX (ref handle );
Finally, the compilation is passed, but this initialization operation is always disgusting. Finally, it is changed to (C ++/CLI ):
Void XXX ([outattribute] intptr % handle );
(C #):
Intptr handle;
XXX (Out handle );