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

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top