C++/CLI Boxing/UnBoxing and Ref/Out Issue

1. Boxing and UnBoxing in C++/CLI

int^ hi = 123;
int c = *hi;

2. Use C# functions with ref/out arguments in C++/CLI

If the argument is dotNet value type, then directly create an instance of it on stack in C++/CLI and pass it when calling the C# function;

if the argument is dotnet ref type,then create a handle of that type and initialize it, and pass it.

More:

c++/cli uses c# module functions having arguments "ref xx", "out xx"
----the C++/CLI code
void foo(Bar^% x);
transforms into
Void foo(ref Bar x);
---The concept of out is for the most part limited to C#. The CLR really only sees ref parameters. The out concepts is achieved via a mod opt I believe and most languages ignore it.
 

 

posted @ 2011-04-21 17:15  能巴  阅读(438)  评论(0)    收藏  举报