Application of IL-essence of interfaces analyzed with IL

Source: Internet
Author: User
Tags reflector

Ildecompilator --ildasm.exeand reflector.exe:

 

I. Introduction to ildasm.exe

This is a soft vstool, which has been described in detail in the article "ildasm.exe -- il decompilation utility;

 

Ii. reflector.exe

So far (10.02.03), the latest version downloaded from the http://www.aisto.com/roeder/dotnet is latest version: 5.1.6.0, here also the classic "Hello world. "Example: When reflector is used. when ext opens an executable file, the main interface is as follows:

 

 

Reflect.exeis more powerful than ildasm.exe. It can decompile Il, C #, Visual Basic, Delphi, MC ++, and even chrome, and its interface is more friendly. Therefore, it is named as an in-depth IlBest weapon!

Let's take a look at the decompiled IlCodeWhat is it like? What is the same as ildasm.exe? The figure is as follows:

 

 

After comparison, you can obtain reflector.exewith a more convenient interface (without many identifiers in ildasm.exe, see the previous blogMsdn help Diagram).

Of course, the reason why reflector.exe is called in-depth IlThe best tool is becauseIt can decompile the Il language and the C # language! In this way, we:It is possible thatSource codeIn the caseProgramSet !!!As shown in the figure above, we find that the source code is fully compiled and correct, which is surprising, and its role must be far-reaching!

 

Reveal the essence of interfaces with IL:

 

I. essence of interfaces

Let's first look at a common interface definition:

The IL code decompiled with reflector.exe is:

 

Visible InterfaceEssentially, CompiledAbstract classThe methods in the interface are compiledAbstract Method(Abstract virtual), there is no implementation body.

 

Ii. Abstract implementation principle of interfaces

First, let's look at the example of the most basic class inheritance interface, such:

 

The corresponding ilcode is compiled with reflector.exe:

 

In this way, we can see that the corresponding interface functions in this class are implemented here."Overwrite" -- override!Therefore, the abstract mechanism of interfaces adoptsPolymorphism!

 

In summary, I learned more about the reflect.exe instance application and the Il decompilation tool. At the same time, the Il code is used to reveal the essence of the interface and realize that it is keeping the interfaceUniqueness(I will not discuss it here .) Abstract class implementation mechanism and its polymorphism.

 

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.