First read CLR via C # Il, CTS, CLS

Source: Internet
Author: User

This chapter describesCLRInIl,CTSAndCLSMake a rough summary. The following chapter begins the content of Chapter 2.

IlWe call it an advanced assembly language or intermediate language.. NetUnder the FrameworkProgram(Whether it isC #,VBOrJ #) At the compilation costCPUAll commands are compiledIlLanguage.CLRPairIlLanguage compilation and control. For exampleVBWrite the following in the console application:Code:

SubMain ()

Console. writeline ("VB")

 End Sub

ReuseC #Write the following code in the console application:

Static VoidMain (String[] ARGs)

{

 Console. Writeline ("Test");

}

Although the syntax is completely different (except for the output is similar ),MsilAfter the disassembly program is loaded and compiledEXEFile,

 

 

 

Figure1.1

 

Figure1.2

 

The two images above1.1After compilation is completeVBLanguage code, diagram1.2After compilation is completeC #As you can see from where I draw the red line, the first line (Red Line) is not the same as the output string, and the second line (Red Line) is exactly the same, that is to say, no matter what language is programmed on the platform, the compiler will eventually compile it into a unifiedIlCode (for example, console output command in the example ). The above example shows thatCLRHow to support multi-language integration only requires different compilers to compile source filesCLROfIlCode, you can. NetRun under the framework.

What isCTS?

CTS(Common Type SystemGeneral Type System) is a specification developed by Microsoft, which expresses a type definition and behavior. SinceCTSIs a set of specifications, so what are the provisions?

I,CTSSpecifies that a type can contain zero or more members (fields, attributes, methods, events );

2. CTS specifies a type of visual principle. The permission modifiers ( Public , private , protected , internal )

III,CTSIt is specified that any type can only be derived from one type, I .e:System. ObjectType. (AlthoughC ++Multi-integration is supported,. NetIf the compiler finds that developers use multi-integrationCTSThe compiler reports an error .)

What isCLS?

CLS ( Common Language Specification common language specifications) is a function supported by Microsoft in various languages. That is, CLS is a subset of CTS , the subset is . net all programming languages under the framework must comply with (if C # communicates with VC ++ applications ). To be more detailed, if you want to use C # to call C ++ components, the syntax used by C ++ (if this method is Public , if the method is not Public , CLS is not restricted ), you must ensure that C # can be operated. However, C ++ programmers do not necessarily know whether C # can operate the method he wrote, in this case, CLS is required, to ensure that C # can normally call C ++ component.

 

Figure1.3

 

Figure1.3As you can see,CLR \ ctsIs. NetAll languages in the framework provide a large set of functions. Every language is usedCLR \ cts. However, this subset containsCLSThis smallest subset. That is to say, the functions and support of all languages are required.CLSThe smallest energy supply set.

In the first chapter of this book, the author only understands these things. There may be more profound things. Due to my limited level, I can only come here. If there is anything wrong or inaccurate, I hope you will be able to raise it immediately. So that the author can learn and correct the mistakes in the blog. Thank you!

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.