编译器错误 C3390

“type_arg”: 对于泛型“generic_type”,泛型参数“param”的类型实参无效,它必须是引用类型

泛型类型实例化错误。 检查类型定义。

备注

有关详细信息,请参阅泛型

示例

第一个示例使用 C# 来创建包含泛型类型的组件。 此类型具有在 C++/CLI 中创作泛型类型时不受支持的某些约束。 有关详细信息,请参阅类型参数的约束

// C3390.cs
// Compile by using: csc /target:library C3390.cs
// a C# program
public class GR<C, V, N>
where C : class
where V : struct
where N : new() {}

当 C3390.dll 组件可用时,以下示例将生成 C3390。

// C3390_b.cpp
// Compile by using: cl /clr C3390_b.cpp
#using <C3390.dll>
ref class R { R(int) {} };
value class V {};
ref struct N { N() {} };

int main () {
   GR<V, V, N^>^ gr2;   // C3390 first type must be a ref type
   GR<R^, V, N^>^ gr2b; // OK - do this instead
}