Generic method and NRT return type - weird compiler warning

104 Views Asked by At

I have the following generic method:

public static T? Foo<T> (string param1, T? param2)
    where T : class, IEnumerable
{
    // ...
}

I get the following compiler error:

Error CS8627: A nullable type parameter must be known to be a value type or non-nullable reference type unless language version '9.0' or greater is used. Consider changing the language version or adding a 'class', 'struct', or type constraint.

However, as you can see, I already added the "class" constraint. So what else am I missing here?

VS 2019 16.8.1

0

There are 0 best solutions below