General understanding C #(13. Version processing)

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.