【问题标题】:C++ IEnumerable<int>=class->method(); in WinFormsC++ IEnumerable<int>=class->method();在 WinForms 中
【发布时间】:2011-10-20 19:00:57
【问题描述】:

我想要与以下 C# 等效的 C++。

List<int> k = myclass.method().ToList();

在我的标准 C++ WinForms 应用程序中,我尝试了以下方法:

IEnumerable<int>^ m=    myclass->method();

我收到以下错误:

C2872 IEnumerable 模糊符号

请帮助我理解并解决我的问题。

【问题讨论】:

    标签: .net visual-c++ compiler-errors c++-cli ienumerable


    【解决方案1】:

    有两个IEnumerables——一个在System::Collections,一个在System::Collections::Generic

    不知何故,两者都在范围内(可能使用 using 指令),因此您需要删除所述 using 指令或完全限定类型名称:

    System::Collections::Generic::IEnumerable<int>^ m = myclass->method();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多