"colson" <ch******@gmail.com> a écrit dans le message de news:
11**********************@p79g2000cwp.googlegroups. com...
| If I have a class A, and a List<List<object>> containing instances of
| A. How do I explicitly cast List<List<object>> as List<List<A>>?
You can't. Do a Google search for covariance, this has been discussed many
times n these groups.
List<A> is not derived from List<object>, even though A is derived from
object; otherwise you could also add untyped objects to a List<A>, thus
defeating the type safety of generic classes.
BTW, why would you use a generic list to hold "object" instances, this
defeats the need for a generic list anyway, you might as well use an
ArrayList. Generic lists are for typesafe lists of instances of the same
type, not heterogeneous lists.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer