官术网_书友最值得收藏!

Understanding MSIL, CLI, CTS, and CLS

When we build our project, the code is compiled into the Intermediate Language (IL), also known as Microsoft Intermediate Language (MSIL). MSIL is compliant with the  Common Language Infrastructure (CLI), where CLI is the standard that provides a common type system and a language specification, respectively known as the Common Type System (CTS) and Common Language Specification (CLS).

The CTS provides a common type system and compiles the language-specific types into the compliant data types. It standardizes all the .NET languages' data types to a common data type for language interoperability. For example, if the code is written in C#, it will be converted to the specific CTS.

Suppose we have two variables, defined in the following code fragment using C#:

class Program 
{ 
  static void Main(string[] args) 
  { 
    int minNo = 1; 
    long maxThroughput = 99999; 
  } 
} 

On compilation, the compiler generates the MSIL into an assembly that will be available through the CoreCLR to perform the JIT and convert it into the native machine code. Note that the int and long types are converted to the int32 and int64 respectively:

It is not necessary for every language to comply completely with the CTS, and it can support the smaller footprint of the CTS, too. For example, when VB.NET was first released in .NET Framework, it only supported the signed integer data types, and there was no provision to use unsigned integers. With later versions of .NET Framework, and now with .NET Core 2.0, we can use all managed languages, such as C#, F#, and VB.NET, to develop applications and easily reference any project's assembly.

主站蜘蛛池模板: 延安市| 黄石市| 东台市| 资兴市| 阳西县| 穆棱市| 吐鲁番市| 册亨县| 龙山县| 扎兰屯市| 阿拉尔市| 南澳县| 徐水县| 浮梁县| 昭通市| 准格尔旗| 江北区| 任丘市| 汉寿县| 积石山| 桂平市| 维西| 宜昌市| 溧阳市| 宜昌市| 道孚县| 隆德县| 西盟| 广平县| 杭锦后旗| 北票市| 洮南市| 永泰县| 繁峙县| 淳安县| 微山县| 黄冈市| 东阳市| 固镇县| 苏尼特右旗| 临沂市|