如何使用CLI函数在c#中使用数组参数?
我想在C#中使用数组,使用CLI函数 CLI源代码如何使用CLI函数在c#中使用数组参数?,c#,c++-cli,C#,C++ Cli,我想在C#中使用数组,使用CLI函数 CLI源代码 public value struct Test { int nIndex; TArrTest Arr; // TArrTest : Array struct } void Api::Set_Test(array<Test^>^% _Test2) Test[] Test3 = new Test[5]; test3[0].nIndex = 0; ... ... Api.Set_Test(
public value struct Test
{
int nIndex;
TArrTest Arr; // TArrTest : Array struct
}
void Api::Set_Test(array<Test^>^% _Test2)
Test[] Test3 = new Test[5];
test3[0].nIndex = 0;
...
...
Api.Set_Test(ref Test3) // Error message
错误消息:
参数不是将ref测试[]转换为ref系统值[]
如何在C++中调用Set#u Test?您的C++/CLI声明:
void Api::Set_Test(array<Test^>^% _Test2)
知道何时使用^hat在C++/CLI中非常重要。仅将其用于引用类型(ref类或ref结构)。%也不正确,C++/CLI函数不创建数组。删除两者。
void Api::Set_Test(array<Test>^% _Test2)
^------ remove the reference caret inside the angle brackets