C #'s replacement principle,
Lee's conversion Principle
Sub-classes can be assigned to parent class objects.
The parent class object can be forcibly converted to the corresponding subclass object.
The principle of RYS replacement is intuitively understood as "sub-class is parent class", which in turn won't work.
Just like a man is right, but a man is wrong.
This is clear.
In the object-oriented thinking, it can be seen that a derived class has all the features that the base class exposes downward. It is a special case of the base class.
When a derived class object is assigned to a base class type, the data structure of the derived class corresponds to the data structure of the Base class in sequence. The data of the derived class is invisible.
When the base class object attempts to convert to a derived type, the data of the base class object cannot be filled with all the data structures of the derived class in sequence. This makes it impossible to complete the function defined by the derived class. The compiler will prompt or even report an error.
This is why the derived class is competent for the basic class function, but the base class is not fully competent for the function of the derived class.
Forced conversion belongs to the process from the base class to the derivation: the designer knows that the data structure of the Base Class Object can completely fill the structure of the derived class. Otherwise, a forced conversion error occurs. It is generally best to avoid strong conversion!
Also, it is not entirely correct that subclass can appear in any parent class object, and sometimes some members of the parent class will not be exposed to the subclass.
C # sample code: http://www.eyesourcecode.com/f/CSharp/1