Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将数组列表传递给本机C++ 我需要把托管数组的列表从C代码传递到本机C++代码。 这是我正在使用的代码 for (int i = 0; i < Digits->Count; i++) { pin_ptr<unsigned char> ptemp = &(Digits[i]->Digit[0]); nativeTemplates.digits.push_back(ptemp); } 我看到传递给本地C++的缓冲区是垃圾。 这是因为当pin_ptr失去循环范围时,缓冲区没有被固定。 使用下面的代码,一切都很好 pin_ptr<unsigned char> ptemp = &(Digits[0]->Digit[0]); nativeTemplates.digits.push_back(ptemp); pin_ptr<unsigned char> ptemp1 = &(Digits[1]->Digit[0]); nativeTemplates.digits.push_back(ptemp1); pin_ptr<unsigned char> ptemp2 = &(Digits[2]->Digit[0]); nativeTemplates.digits.push_back(ptemp2); . . . pin_ptr<unsigned char> ptempn = &(Digits[n]->Digit[0]); nativeTemplates.digits.push_back(ptempn);_C#_C++_Command Line Interface_Native_Managed - Fatal编程技术网

C# 将数组列表传递给本机C++ 我需要把托管数组的列表从C代码传递到本机C++代码。 这是我正在使用的代码 for (int i = 0; i < Digits->Count; i++) { pin_ptr<unsigned char> ptemp = &(Digits[i]->Digit[0]); nativeTemplates.digits.push_back(ptemp); } 我看到传递给本地C++的缓冲区是垃圾。 这是因为当pin_ptr失去循环范围时,缓冲区没有被固定。 使用下面的代码,一切都很好 pin_ptr<unsigned char> ptemp = &(Digits[0]->Digit[0]); nativeTemplates.digits.push_back(ptemp); pin_ptr<unsigned char> ptemp1 = &(Digits[1]->Digit[0]); nativeTemplates.digits.push_back(ptemp1); pin_ptr<unsigned char> ptemp2 = &(Digits[2]->Digit[0]); nativeTemplates.digits.push_back(ptemp2); . . . pin_ptr<unsigned char> ptempn = &(Digits[n]->Digit[0]); nativeTemplates.digits.push_back(ptempn);

C# 将数组列表传递给本机C++ 我需要把托管数组的列表从C代码传递到本机C++代码。 这是我正在使用的代码 for (int i = 0; i < Digits->Count; i++) { pin_ptr<unsigned char> ptemp = &(Digits[i]->Digit[0]); nativeTemplates.digits.push_back(ptemp); } 我看到传递给本地C++的缓冲区是垃圾。 这是因为当pin_ptr失去循环范围时,缓冲区没有被固定。 使用下面的代码,一切都很好 pin_ptr<unsigned char> ptemp = &(Digits[0]->Digit[0]); nativeTemplates.digits.push_back(ptemp); pin_ptr<unsigned char> ptemp1 = &(Digits[1]->Digit[0]); nativeTemplates.digits.push_back(ptemp1); pin_ptr<unsigned char> ptemp2 = &(Digits[2]->Digit[0]); nativeTemplates.digits.push_back(ptemp2); . . . pin_ptr<unsigned char> ptempn = &(Digits[n]->Digit[0]); nativeTemplates.digits.push_back(ptempn);,c#,c++,command-line-interface,native,managed,C#,C++,Command Line Interface,Native,Managed,我的问题是,如何在不显式编码列表中每个成员的固定的情况下执行所需操作。nativeTemplates.digits的定义是什么?它是一个向量,您可以将字符放入StringBuilder中,并将字符串传递给本机代码。当固定指针超出范围时,对象不再被视为固定,因此如果使用pin_ptr,似乎必须坚持此解决方案。

我的问题是,如何在不显式编码列表中每个成员的固定的情况下执行所需操作。

nativeTemplates.digits的定义是什么?它是一个向量,您可以将字符放入StringBuilder中,并将字符串传递给本机代码。当固定指针超出范围时,对象不再被视为固定,因此如果使用pin_ptr,似乎必须坚持此解决方案。