我在處理從C#應用程序接收到的字符串^的數組時出現問題。爲什麼我不能創建一個String ^數組? 我對C++相當陌生,所以不勝感激。不允許使用數組的句柄C++
public ref class Example
{
public:
String^ Convert(String^ pointNames[], String^ outputPath)
{
std::string convertedPath = msclr::interop::marshal_as<std::string>(outputPath);
std::string result = otherFunction(pointNames, convertedPath);
return msclr::interop::marshal_as<String^>(result);
}
};
pointsNames []帶下劃線作爲錯誤,消息:不允許使用數組句柄。
將一個字符串數組從C#應用程序發送到C++會更好嗎?
快速搜索建議將'String^pointNames []'改爲'WriteOnlyArray^pointNames' - 你可以試試嗎? –
Thebluefish
@Thebluefish我不知道我明白了,我用WriteOnlyArray替換了String^ ^但編譯器只是說WriteOnlyArray不是一個模板,我必須包含一些庫嗎? –
它看起來像屬於「平臺」命名空間 - 取自[本文](https://social.msdn.microsoft.com/Forums/en-US/f0e968b2-5798-430a-8a00-d45c4a9ef1e0/pointer-對AC-陣列的帽型手柄?論壇= winappswithnativecode)。 – Thebluefish