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);
?
The ref keyword in C# is used for passing or returning references of values to or from Methods. Basically, it means that any change made to a value that is passed by reference will reflect this change since you are modifying the value at the address and not just the value.
ref new, gcnew (C++/CLI and C++/CX)The ref new aggregate keyword allocates an instance of a type that is garbage collected when the object becomes inaccessible, and that returns a handle (^) to the allocated object.
A ref class can contain public , protected , and private function members; only public and protected members are emitted into metadata. Nested classes and ref classes are permitted but cannot be public .
The ref keyword tells the compiler that the class or structure will be allocated on the heap and a reference to it will be passed to functions or stored in class members. The value keyword tells the compiler that all of the data in the class or structure is passed to functions or stored in members.
You can use the OutAttribute:
using namespace System::Runtime::InteropServices; void foo([Out] Bar^% x);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With