How to return a byte[] to C# in C++ CLR
I'm us开发者_C百科ing C++ CLR to wrap a native C++ dll. So that the C++ CLR dll can be accessed by a C# project.
The problem is that when I want to return a byte[] to C#, and write such code in CLR:
static System::Byte[]^ GetTestByteBuffer()
{
System::Byte[]^ byte = gcnew System::Byte[128];
return byte;
}
but it cannot pass compilation. Anyone can help me?
compilation error:
error C3409: empty attribute block is not allowed
error C3409: empty attribute block is not allowed error C2146: syntax error "^":
error C2334: unexpected token(s) preceding '{'; skipping apparent function
This is the way you declare a byte array in C++/CLI:
array<System::Byte>^
Google is your friend...
精彩评论