Possible Duplicate:
polymorphic resolution of generic parameters in Unity registerType
This is probably obvious. But can someone tell me why this is not valid code?
The compiler says it can't convert Class1<string>
to Class1<object>
.
Is upcasting this way not allowed with generics? If so, why not?
namespace Test
{
public class Tests
{
public void Test()
{
Class1<object> objectClass1 = new Class1<string>();
}
}
class Class1<T>
{
}
}