托管C ++中的泛型泛型 [英] Generic Generics in Managed C++
本文介绍了托管C ++中的泛型泛型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在托管C ++项目中创建 KeyValuePair 的 List 。这里是我使用的语法
I want to create a List of KeyValuePairs in a managed C++ project. Here is the syntax I'm using
List<KeyValuePair<String^, String^>^>^ thing;
但我收到以下错误:
but I'm getting the following error:
错误C3225:'T'的泛型类型参数不能是'System :: Collections :: Generic :: KeyValuePair ^',它必须是值类型或引用类型的句柄
我基本上想这样做(C#)
I basically want to do this (C#)
List<KeyValuePair<string, string>> thing;
但是在托管的C ++中。哦,在.Net 2.0中。任何接收者?
but in managed C++. Oh and in .Net 2.0. Any takers?
推荐答案
KeyValuePair本身不需要是句柄。 Duh。
KeyValuePair does not itself need to be a handle. Duh.
因为它是一个值类型,而不是引用类型(即 struct
代替C#中的 class
)。
Because it's a value type, not a reference type (i.e. struct
instead of class
in C#).
这篇关于托管C ++中的泛型泛型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文