Understanding the Common Type System in Real Scenarios Using The MSIL DisAssembler

If I talk about .NET then what is CTS aka Common Type System?
 

Introduction

 
Every language (in .Net Framework) has its own data types that are represented by a class or structure and collection of all the classes and structures related to data types called Common Type System (CTS).
 
Every language provides its own keywords for data types but internally all the languages that run under the .NET framework use the classes and structures available in the CTS.
 
For example, C# has the int data type and VB.Net has the Integer data type. Hence a variable declared as an int in C# or Integer in vb.net, and finally, after compilation, use the same structure "int32" from the CTS.
 
Motive
 
All the structures and classes available in the CTS are common for all .NET Languages and the purpose of these is to support language independence in .NET, so this motive is resolved by the CTS.
 
Explanation with a real example: To explain the CTS I will create 2 console applications in 2 different languages:
  1. VB.Net
  2. C#

VB.Net

 
Step 1: Create first a Console application in VB.Net named "ConsoleApp_VB".
 
Console Application
 
Step 2: Create a variable of Integer type and assign a value, like 10, and build the application, that generates the .exe file in the bin folder of the project.
  1. Dim i As Integer = 10 
variable of Integer type
 
Step 3: Open "IL Disassembler" by selecting the Start menu then "Microsoft Visual Studio 2010" -> "Microsoft Windows SDK Tools".
 
IL Disassembler
 
Note: I am using Visual Studio 2010.
 
Step 4: Open your .exe file that exists in the bin folder of the project via "File" -> "Open".
 
exe file
 
Step 5: The .exe file loads in "IL Disassembler" after the selection, that will look like :
 
IL Disassembler
 
Step 6: Now double-click on the "Main" method that shows the following window where you can see your variable "i" that was Integer type and now it converts into "int32".
 
IL Disassembler with type
 

C#

 
Now I will do the same process from Step 1 to Step 6 for C#.
 
Step 1: Create the first Console application in C# named "ConsoleApp_CS".
 
 
Step 2: Create a variable of int type and assign a value like 10 and build the application that generates the .exe file in the bin folder of the project.
  1. int i = 10; 
bin folder of the project
 
Step 3: Again open the "IL Disassembler" by selecting the Start menu then "Microsoft Visual Studio 2010" -> "Microsoft Windows SDK Tools".
 
Note: I am using Visual Studio 2010.
 
Step 4: Open your .exe file that exists in the bin folder of the project via "File" -> "Open".
 
exe file
 
Step 5: The .exe file loads in "IL Disassembler" after the selection, that will look like:
 
exe file loads in IL Disassembler
 
Step 6: Now double-click on the "Main" method that shows the following window where you can see your variable "i" that was an int type and now it converts into "int32".
 
int type converted into int32
 

Conclusion

 
I hope now you have an understanding of the Common Type System that converts both the Integer of VB.Net and int of C# into int32.