byte[] as output parameter in managed C++

S

Smugsboy

Hello,
I would like to know the managed C++ syntax of the following method
(defined in C#):

void temp(out byte[] byteArr).


I tried something like:
void temp([Out] byte byteArr __gc[])

But it didn't work.

Thanks,
 
T

Tomas Restrepo \(MVP\)

Hello,
I would like to know the managed C++ syntax of the following method
(defined in C#):

void temp(out byte[] byteArr).


I tried something like:
void temp([Out] byte byteArr __gc[])

first, replace byte with Byte.

Next, the following should work:

using namespace System::Runtime::InteropServices;

void temp([Out] Byte (* byteArray)__gc[])
 
S

Smugsboy

Thanks,
That did the trick for me.

How ever I'm not fimiliar with the syntax.
The syntax you've suggested:
void temp([Out] Byte (* byteArray)__gc[])

is not like:
void temp([Out] Byte __gc* byteArray __gc[])

What does (*byteArray) mean ? (looks like the syntax for function
pointers ...



Hello,
I would like to know the managed C++ syntax of the following method
(defined in C#):

void temp(out byte[] byteArr).


I tried something like:
void temp([Out] byte byteArr __gc[])

first, replace byte with Byte.

Next, the following should work:

using namespace System::Runtime::InteropServices;

void temp([Out] Byte (* byteArray)__gc[])
 
T

Tomas Restrepo \(MVP\)

That did the trick for me.
How ever I'm not fimiliar with the syntax.
The syntax you've suggested:
void temp([Out] Byte (* byteArray)__gc[])

is not like:
void temp([Out] Byte __gc* byteArray __gc[])

What does (*byteArray) mean ? (looks like the syntax for function
pointers ...

Nope, it is just to ensure the correct interpretation. Without the (), it
could be interpreted as an array of pointers to Byte, which is not what you
want. You need to be interpreted as a pointer to an array of Byte, which is
different :)
 

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