Compiler Error C3228
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3228.
function' : generic type argument for 'param' cannot be 'type', it must be a valuetype or handle type
An incorrect type was passed as a generic type argument.
The following sample generates C3228:
// C3228.cpp
// compile with: /clr
class A {};
value class B {};
generic <class T>
void Test() {}
ref class C {
public:
generic <class T>
static void f() {}
};
int main() {
C::f<A>(); // C3228
C::f<B>(); // OK
Test<C>(); // C3228
Test<C ^>(); // OK
}
Show: