gpt4 book ai didi

c# - 在 System::Collections::Generic::List 类型的列表中列出是可能的吗?

转载 作者:行者123 更新时间:2023-11-28 02:22:55 25 4
gpt4 key购买 nike

在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com