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


Categories

Top Posts

Tags

.NET addin app.config ArrayList bug CAB Configuration ConfigurationManager ConfigurationSection ContentControl ContextMenu CTime; DateTime custom keys DataBinding DataContext Data templates debugging equals gethashcode GUI Hashtable interlocked Invoke lock lock free memcpy MFC multithreading multithreading; lock free override performance SCSF serialization Smart Client Software Factory Styles System.Configuration unsafe virtual functions Visual Studio wait free WinAPI WinForms WinForms\WPF Integration World of Warcraft World of Warcraft; Addon

Archives