在 C# 中:
public static List<List<int>> StopCapture()
{
List<List<int>> Data = new List<List<int>>();
//data.add() some data is added is here
return Data;
在 C++ 中: 我正在尝试像这样收集
List<List<int>^>^ captureCommandStrings = gcnew List<List<int>>();
captureCommandStrings = StopCapture();
错误: “T”的泛型类型参数不能是“System::Collections::Generic::List”,它必须是值类型或引用类型的句柄
提前致谢
最佳答案
您在实例化结束时忘记了“帽子”:
List<List<int>^> ^Data = gcnew List<List<int>^>();
即,如果您将“数据”声明为指向指向 int 列表的托管指针列表的托管指针,那么您的实例化还必须创建指向 int 列表的托管指针列表(而不是列表的列表)。
关于c# - 在 System::Collections::Generic::List<T> 类型的列表中列出是可能的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31726121/