2008-12-04 58 views
2

我想在托管C++项目中创建一个列表KeyValuePair。下面是我使用托管C++中的通用泛型

List<KeyValuePair<String^, String^>^>^ thing; 

,但我发现了以下错误的语法:

error C3225: generic type argument for 'T' cannot be 'System::Collections::Generic::KeyValuePair ^', it must be a value type or a handle to a reference type

我基本上要做到这一点(C#)

List<KeyValuePair<string, string>> thing; 

但在管理C++。哦,在.Net 2.0中。任何接受者?

回答

2

KeyValuePair does not itself need to be a handle. Duh.

因为它是一个值类型,不是引用类型(即struct代替class在C#)。

3

想通了:

List<KeyValuePair<String^, String^>>^ thing; 

KeyValuePair本身并不需要是一个手柄。咄。