When I'm trying to use Covariance
and Contravariance
on classes I'm getting an error that variant parameters can be applied only on interfaces and delegates.
// This will compile successfully
interface IInterface<out T>
{
}
// This will produce error at compile time
class MyClass<out T>
{
}
For the second case(with classes) Compiler is displaying the below message:
Any idea why C# has such restrictions?