C++ IEnumerable=class->method();在WinForms中

发布于 2024-12-11 08:17:08 字数 399 浏览 1 评论 0原文

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

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

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

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

我收到以下错误:

C2872 IEnumerable 不明确符号

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

I want the C++ equivalent to the following C#.

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

In my standard C++ WinForms application I have tried the following:

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

I get the following error:

C2872 IEnumerable ambiguous symbol

Please help me understand and resolve my issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开浅夏 2024-12-18 08:17:08

有两个 IEnumerable,一个在 System::Collections 中,一个在 System::Collections::Generic 中。

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

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

There are two IEnumerables -- one in System::Collections, and one in System::Collections::Generic.

Somehow you have both in scope (probably with using directives), so you'll need to either remove said using directives or fully qualify the type name:

System::Collections::Generic::IEnumerable<int>^ m = myclass->method();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文