Passing by Reference between C++ and C# using VS.NET 2005 Beta 2

  • Thread starter Thread starter Chris Mullins
  • Start date Start date
C

Chris Mullins

I've got a C++ DLL that I'm trying to pass a value type into by reference.
My C++ class looks like:
public ref class Class1
{
public:
System::Boolean DoSomething(System::Boolean &b)
{
b = !b;
return True;
}
};

My C# code (that won't compile) looks like:

Boolean b = true;
Class1 z = new Class1();
z.DoSomething(ref b);

I've tried all sorts of things without any luck. My first attempt in C++
had:
System::Boolean DoSomething(System::Boolean ^b)
.... but that's a a pass-by-value, and won't allow the calling method to
change the value.


What am I missing?
 
Back
Top