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

标签 c# c++

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

相关文章:

c# - 如何读取 excel (.xlsm) 文件,该文件通过 C# 使用finansu 插件

c# - 以 DataTable 作为源的 GridView 不自动分页或排序

c++ - 如何在 Vista/Server 2008 上使用 std::shared_mutex?

c++ - 如何将 _variant_t 数据类型转换为 wstring

java - 使用 FFMpeg 将 BGR BufferedImage 快速转换为 YUV

c# - Microsoft.IdentityModel 与 System.IdentityModel

c# - 如何使用类似插件的架构来扩展 WPF 应用程序?

c# - Kinect错误启用流

C++ casted realloc 导致内存泄漏

c++ - Allegro 5 如何绘制缩放位图区域