The principle of the Richter conversion
Subclasses can assign values to parent class objects
Parent-class objects can be coerced into corresponding subclass objects
The principle of the Richter substitution is intuitively understood to mean that the subclass is the parent class, which in turn does not make sense.
It's like a man is right, but a man is wrong.
That's clear.
In object-oriented thinking, a derived class has all the characteristics that the base class exposes downward, which is a special case of the base class.
When a derived class object is assigned to the base class type, the following occurs: The data structure of the derived class corresponds to the database of the basis class in turn. and the derived class has its own data that will not be visible.
When an object of the base class attempts to convert to a derived type, the data for the base class object cannot be populated in turn all the data structures of the derived class. This causes it to fail to complete the functionality defined by the derived class. The compiler will prompt or even make an error.
This is why the derived class is capable of the base class function, but the base class is not fully qualified for the function of the derived class.
Casting is a base class to a derived procedure: That's because the designer knows that the data structure of the base class object can completely fill out the structure of the derived class. Otherwise, a strong-go error occurs. Generally it is best to avoid the use of strong turn!
Also, it is not entirely true that a subclass can appear where any parent class object appears, and the parent class sometimes does not expose some of its members to subclasses.
C # sample code: HTTP://WWW.EYESOURCECODE.COM/F/CSHARP/1
The Richter substitution principle in C #