IList to IList

后端 未结 8 1066
猫巷女王i
猫巷女王i 2021-01-05 00:28

I have a few classes:

class Vehicle
{
}

class Car : Vehicle
{
}

I have a list of the derived class: IList cars;

8条回答
  •  感情败类
    2021-01-05 00:51

    That sort of polymorphism that lets you cast IList to IList is unsafe, because it would let you insert a Truck in your IList.

提交回复
热议问题