Archive for November, 2008
Passing value types by reference (a ref keyword) to the managed C++ (CLI)
Hi, after a little research I did to accomplish this task, I thought it would be nice to share the solution with my readers, so here it is: in the CLI method you should use a “%” keyword, it is the same as “ref” in the C#.
Example: (passing integer by ref from C# to CLI)
declaring method in the CLI:
MyClass::MyMethod(Int32% myValue);
calling that method from C#:
MyClass myClass = new MyClass();
int myValue = 12;
myClass.MyMethod(ref myValue);
Hope that was helpful,
Evgeni
Add comment November 26, 2008