Parameters visible in C# as 'ref' args ?

S

Steve Terepin

I've been trying to make a Managed C++ method that appears with the following signature in C# :

void Func ( ref bool cancelRequest )

.... but if I declare it in C++ as simply

void Func ( bool & cancelRequest )

.... it appears in the C# world as ( bool * ).

I've tried adorning the declaration with attributes like this :

void Func (
[System::Runtime::InteropServices::InAttribute]
[System::Runtime::InteropServices::OutAttribute]
bool & cancelRequest
) ;

.... but that doesn't do the trick.

Any ideas, anyone ?

Steve.
 
M

Mattias Sjögren

Steve,
I've been trying to make a Managed C++ method that appears with the following signature in C# :

void Func ( ref bool cancelRequest )

Try

void Func( bool __gc* cancelRequest )

or

void Func( System::Boolean *cancelRequest )



Mattias
 
S

Steve Terepin

Thanks, that works now :)))

And if I want the arg to appear as 'out' rather than 'ref', I simply apply
the InteropServices 'OutAttribute'. Nice !!

S.
 

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