我们无法根据父类强制转换为子类 [英] Unable to Cast from Parent Class to Child Class
问题描述
我想从父类转换为子类,但我得到一个InvalidCastException。子类只有int类型的一个属性。有谁知道我需要做什么?
I am trying to cast from a parent class to a child class but I get an InvalidCastException. The child class only has one property of type int. Does anyone know what I need to do?
推荐答案
您不能施放哺乳动物为狗 - 它可能是一只猫
You can't cast a mammal into a dog - it might be a cat.
您不能投了食物放进三明治 - 这可能是一个汉堡
You can't cast a food into a sandwich - it might be a cheeseburger.
您不能投了轿车进入法拉利 - 这可能是本田,或者更具体地说,你不能投法拉利360摩德纳法拉利360 Challange Stradale的 - 有部分不同的充,尽管他们都法拉利360。
You can't cast a car into a Ferrari - it might be a Honda, or more specifically, You can't cast a Ferrari 360 Modena to a Ferrari 360 Challange Stradale - there are differnt parts, even though they are both Ferrari 360s.
这篇关于我们无法根据父类强制转换为子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!