ref and out in C++/CLI

Alexandre C. picture Alexandre C. · Aug 18, 2010 · Viewed 17.7k times · Source

I know that the C++/CLI code

void foo(Bar^% x);

transforms into

Void foo(ref Bar x);

What is the C++/CLI code that becomes

Void foo(out Bar x);

?

Answer

Yochai Timmer picture Yochai Timmer · Jun 13, 2011

You can use the OutAttribute:

using namespace System::Runtime::InteropServices;    
void foo([Out] Bar^% x);