byte[] as output parameter in managed C++

  • Thread starter Thread starter Smugsboy
  • Start date Start date
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,
 
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[])
 
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[])
 
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 :)
 
Back
Top