如果我有两个类,A和B,其中B派生自A:
class A {} class B : A { }
我可以非常高兴地将B的实例转换为A.
B b = new B(); A a = b;
现在,我可以理解运行时如何确定底层类型是B,如ECMA-335(公共语言基础结构(CLI)分区I到VI)的第132页所述
Objects of instantiated types shall carry sufficient information to
recover at runtime their exact type (including the types and number of
their generic arguments). [Rationale: This is required to correctly
implement casting and instance-of testing,as well as in reflection
capabilities
那么,运行时如何知道虽然底层类型是B,但它实际上存储在A中.我知道我不会看到B上可用的方法,但如果底层类型是B,那么它存储存储位置A的类型?
那有意义吗?