C#C
C#3y ago
lukkasz323

❔ ✅ I can't convert List<BaseClass> to List<T> where T: BaseClass.

I have a List<List<Component>>. Component is a base class, and each item in this outer list is actually a List with different sub-classes of Component. At run-time I expect it to look like this:

List<List<Component>>:
  List<SubComponentA>
  List<SubComponentB>
  List<SubComponentC>

Everything works nicely besides this - I can't find a way to get for example List<SubComponentA> from the outer list. Here's my current attempt:
image.png
image.png
image.png
Was this page helpful?