Polymorphic resolution of generic parameters in Unity registerType?

You cannot do this because generics are not covariant. That is, the type itr list1 = new List(); list1. Add(" World!"); // This cast will fail, because the following line would then be legal: List list2 = (List)list1; // ints are objects, but they are not strings!

List2. Add(1) So accessing list11 would return a boxed int in a list that was declared to contain string s Therefore, this cast is not allowed since it would break the type system (As a side note, in the clause where t : class, base you do not need to specify class base itself is a reference type, so the class constraint is redundant.).

You cannot do this because generics are not covariant. That is, the type itr cannot be converted to itr, even though derived1 can be converted to base. Here's an example of why, using the framework List class: List list1 = new List(); list1.

Add(" World! "); // This cast will fail, because the following line would then be legal: List list2 = (List)list1; // ints are objects, but they are not strings! List2.

Add(1); So accessing list11 would return a boxed int in a list that was declared to contain strings. Therefore, this cast is not allowed since it would break the type system. (As a side note, in the clause where t : class, base, you do not need to specify class.

Base itself is a reference type, so the class constraint is redundant. ).

Thanks. I agree. – Manish Nov 24 '10 at 17:07.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions