13. Version Processing
Resolving the version issue has become a major concern of the. NET Framework. Most of these considerations are reflected in the combination. In C #, the ability to run different versions of the same combination in the same process is impressive.
When a new version of the Code (especially the. NET Library) is created, C # can prevent software failure. The C # Language Reference describes the problem in detail. An example is as follows:
In Java, assume that we deploy a class called D, which is derived from a class named B released through VM. Class D has a method named foo, and B does not have this method when B is released. Later, I upgraded class B. Now class B includes a foo method. The new VM is now installed on the machine that uses Class D. Now, the software that uses D may fail, because the new implementation of Class B may lead to a virtual function call to D, which executes an unexpected action of Class B. Note: the default method in Java is virtual.] in C #, the foo method of class D should be declared as without override modifier (this truly expresses the programmer's will ), therefore, the runtime knows that let the foo method of class D hide the foo method of Class B, rather than reload it.
An interesting reference to C #'s Reference Manual is "C # processing version problems is implemented by developers who need to clarify their intentions ". While using override is a way to express intent, the compiler can also automatically generate an overload by checking whether the method is being executed (rather than declared) at compile time. This means that you can still have the same language as Java (Java does not use the virtual and override keywords) and still be able to correctly handle version issues.
See the field modifier section.