I've the below code.
interface ITest<in T> where T: Message
{
void Print(T t);
}
abstract class Message
{
}
class SimpleMessage: Message
{
}
class Test: ITest<SimpleMessage>
{
public void Print(SimpleMessage message)
{
}
}
Why the below statement is throwing error?
ITest<Message> test = new Test();
Severity Code Description Project File Line Suppression State Error CS0266 Cannot implicitly convert type 'Test' to 'ITest<HelloAspose.Message>'. An explicit conversion exists (are you missing a cast?)