What are CTS, CLS, CLR, CTS, CLSCLR?
CTS, CLS, and CLR are basic concepts of the. NET Framework, but they are often ignored by programmers. A clear understanding of the three concepts helps. NET programmers write efficient and secure. NET programs.
Knowledge points involved
• Basic concepts of. NET
• Relationship between CLS, CTS and common languages
Analyze problems
The full name of CLR is the Common Language Runtime. Readers can understand CLR as a set of engines that contain. NET programs and libraries that conform to the basic structure of the Common Language. CLR is a standard implementation. Almost all. NET programs we develop are implemented based on CLR class libraries and run on the running engine provided by CLR. The. NET Framework refers to the public Language Runtime Library.
The common language infrastructure (CLI) is a language and data format specification submitted by Microsoft to ECMA. CLR is the only implementation version of the common language infrastructure so far.
The full name of CTS is the Common Type System ). The previous article has introduced the concept of the Basic Public language (CLI). The CLI specifications submitted by Microsoft include the Common Type System (CTS) and the common intermediate language (CER) file Format and metadata format at the bottom. A common type system defines a language specification that can run on CLR. Although many languages do not comply with the CTS specification, many languages can compile programs that can run on CLR by enhancing the compiler and changing the language's additional specification.
Compiling a program written in a language can run on the CLR. It does not mean that the language fully complies with the CTS specifications. For example, the C ++ language keeps the section that does not comply with the CTS specification, and compiles the code that does not comply with the CTS into the original code rather than the intermediate code during compilation.
Finally, let's take a look at the concept of CLS. The common language specification (CLS) is a subset of CTS and defines the minimum specification required for the language of the program to be written on the. NET platform. Because. NET allows programs written in different languages to run together, CLS specifications are developed to avoid errors caused by different language features.
To better understand CLS, let's look at this section of C # code:
Code 2-1 CLS specification: CLS. cs
Using System;
Using System. Collections. Generic;
Using System. Text;
// Declare that C complies with CLS specifications
[Assembly: CLSCompliantAttribute (true)]
Namespace NET. MST. Second
{
Public class CLS
{
Private uint I; // This is a private member, so it does not violate the CLS specification.
Public CLS ()
{
I = 0;
}
Static void Main (string [] args)
{
}
// The uint is not defined in CLS because it does not comply with the CLS specification.
Public uint GetI ()
{
Return I;
}
}
}
In code 2-1, the program declares that the CLS type must comply with the CLS Specification through the CLSCompliantAttribute feature. The uint type in C # does not have a corresponding type in CLS, so uint is a language part that does not conform to CLS. At the beginning of the CLS class, the program defines a uint type private member variable I, which does not cause the CLS class to not comply with the CLS rules, because the private variables are only visible to the class. The program then defines a public method to return the uint type, which causes the entire CLS type to not comply with the CLS specification. Compile this code and get the following warning:
C: \ David \ net mst \ chapter \ CLS. cs (23,21): warning CS3002: Return type of 'net. MST. second. CLS. getI () 'is not CLS-compliant
Now, the reader has understood the relationship between CLS and CTS.
Answer
The Common Language Runtime Library (CLR) is a CLI implementation that includes the. NET runtime engine and a class library compliant with the CLI.
The general type System (CTS) is included in the CLI specification submitted by Microsoft and defines a type specification that can run on CLR.
The common language specification is a subset of CTS and defines the minimum specification set that all. NET-oriented programs need to comply.
What are the explanations of CTS, CLS, and CLR?
What are the explanations of CTS, CLS, and CLR? CTS: general language system. CLS: general language specification. CLR: Common Language Runtime Library.
What are CTS, CLS, and CLR?
When CLR is running in a common language, CTS is a general-purpose system. cls I don't know if ni is going to Baidu to search. Are You Even lazy than me !!!