急!!请问C#怎么调用C++的dll,把字节数组(字节数组byte[]作为形参)传入C++?
C++:
----------------------------------
extern "C" __declspec(dllexport) int index(char* a);
int __declspec(dllexport) index (char* a)
{
for (int i = 0; i < 10; i++)
{
cout << a[i] << endl;
}
return 0;
}
C#:
--------------------------------------
public void Main(string[] args)
{
[DllImport("DllTest1.dll", EntryPoint = "test")]
public static extern int test(byte[] a);
static void Main(string[] args)
{
byte[] a= new byte[10];
for(int i = 0; i < 10; i++)
{
a[i] = 3;
}
test(a);
}
}
这样字节数组传递不过去,请问C#用的是byte[],C++那边应该用什么类型来接收??