I have this code:
public T? Foo<T>()
where T : class?
{
return null;
}
It gives an error that is logical and expected:
A nullable type parameter must be known to be a value type or non-nullable reference type. Consider adding a 'class', 'struct', or type constraint.
Now I add one more constraint:
public T? Foo<T>()
where T : class?, IDisposable // Could be any interface I guess
{
return null;
}
Now interestingly enough error has just disappeared. Though it really seems to me we have conflicting constraints since interface is non-nullalbe
while class?
is.
Am I missing something here or is there a trouble with compiler?