We generally use the new modifier on Class Members to redefine non-Virtual members inherited from the base class. However, we do not recommend that you do this, this is because redefinition of non-virtual methods can lead to ambiguous behaviors.
Non-virtual methods are statically bound, and the compiler does not determine which method should be called Based on the object runtime type. virtual functions use dynamic binding, the compiler determines the method to be called Based on the runtime type of the object.
Avoid using the new modifier to redefine non-virtual methods. It does not mean that you should design all methods in the base class as virtual methods. When the library designer defines a method as a virtual method, it actually creates a contract for the type, indicating that any derived class can change the implementation of the virtual method. In fact, the virtual method set defines all the behavior that may change in the derived class. The design of "default setting as virtual method" indicates that the derived class can change all behaviors of the parent class, which means that we did not carefully consider what behavior the derived class will change, this is inappropriate. We should spend more time carefully considering which methods and attributes should be declared as polymorphism members. We should declare these members as virtual members only. Do not consider this practice as a restriction on class users. Instead, we should regard this practice as an entry point for custom type behavior.
Only in one case, we need to use the new modifier to redefine the virtual method: After we use the new base class, it is found that the newly added method name in the base class conflicts with the existing method name in the sub-column.
Conclusion: when using the new modifier, we should be very careful. If we use it indiscriminately, there will be ambiguous method calls on the object. The new modifier is considered only when the new base class addition method conflicts with the existing method in the subclass. Even in this case, we should consider it with caution. In addition, we should not use the new modifier in any other situation.