0

我想将 .Net 中的 Action 和 Func 委托泛型用于 C++/CX Windows Store 应用程序。它们也是 WinRT 的一部分吗?

delegate void f( int );

ref class Sample
{
   ...
   event f^ Rendered; // this works
   event Action<int>^ Rendered; // ??? I want something like this using existing lib without creating templates on my own (which Namespace/Header) ???
   ...
}
4

1 回答 1

1

没有“用于 Window Store 应用程序的 C++/CLI”之类的东西。只有 C# 和 VB.NET 获得了 Store 处理,并且可以利用 CLR 中内置的 WinRT 语言投影。在 C++/CLI 中使用该语言投影也不是完全不可能的,但是您无法从该工具中获得任何帮助。

您使用一种称为 C++/CX 的语言。这根本不是基于 .NET 的语言。它是非常原生的 C++,直接编译为机器码。它可以帮助您使用带有与 C++/CLI 非常相似的语言语法扩展的 WinRT 类型。就像ref class语法一样。但由于它不是 .NET 语言,因此无法利用 .NET 类。

语言的基本介绍在这里

于 2012-11-03T21:07:16.190 回答