Casting generics

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vidar_

    Casting generics

    Hi!

    I have a method GetCars that return a List<AbstractCa r>. I want to cast
    the list to List<Toyota>, but it doesn't work:


    List<Toyota> cars = (List<Toyota>)M yContent.GetCar s("Toyota");


    Do I have to manually cast every object in the list when fetching them
    from the list?

Working...