Compiler Error CS0452

The type 'type name' must be a reference type in order to use it as parameter 'parameter name' in the generic type or method 'identifier of generic'

This error occurs when you pass a value type such as a struct or int as a parameter to a generic type or method that has a reference type constraint.

Example

The following code generates error CS0452.

// CS0452.cs
using System;
public class BaseClass<S> where S : class { }
public class Derived1 : BaseClass<int> { } // CS0452
public class Derived2<S> : BaseClass<S> where S : struct { } // CS0452