Common Type System (CTS) in .NET

CTS

 
The Common Type System (CTS) standardizes the data types of all programming languages using .NET under the umbrella of .NET to a common data type for easy and smooth communication among these .NET languages.
 
How CTS converts the data type to a common data type
 
To implement or see how CTS is converting the data type to a common data type, for example, when we declare an int type data type in C# and VB.Net then they are converted to int32. In other words, now both will have a common data type that provides flexible communication between these two languages.
 
CTS
 
Let's take a live example using a Double data type and we will see how .NET helps to make the data types of C# and VB.NET common to each other for easy communication.
 
Live Example
 
We will create a new Visual Basic (Console Application) project.
 
console
 
Now we will add one more project of Visual C# (Console Application).
 
console application
 
Now to see how CTS is helping with the data types of the programming languages and providing a common environment we will declare a Double data type (*note you can use other variables for your reference) variable in both the C# program.cs and Module1.vb.
 
C# Data type Declaration
 
Visual Basic Data type Declaration
 
Visual Basic Data type Declaration
 
Visual Studio x64 Command Prompt
 
Now start debugging both of these Console Applications. Once you are done with Debugging the application, we will now use an important tool provided with Visual Studio Called “ILDASM”.
 
You can learn about “ILDASM” by Control + Click on the “ILDASM” link and gain information on how ILDASM is helpful. So returning back to CTS, now open “ILDASM” from the Visual Studio x64 Command Prompt (2010).
 
execution of the Command
 
After execution of the command, the “ILDASM” window will open as in the following:
 
IL DASM
 
So now to check how CTS converts the data type of C# and VB.Net to be common to each other we will open two “ILDASM” programs then click on File then open the exe file of the desired application. Here we have created VBCONSOLE and C#, so now we will open the .exe in “ILDASM”.
 
ILDASM
 
Now once we have opened both of the Console Applications the “ILDASM” window will appear as in the following snapshot.
 
Click on Visual Basic
 
Click on Visual Basic and then on VisualBasic.Module1, you can see there is a void main function as shown below.
 
Click on Main
 
Click on Main : void()
 
converted to float64
 
You will find that the Double variable is converted to float64 and the same in case of the C# Console Application the Double variable is converted to float64.
 
CTS converting data type to Common type for both programming languages
 
CTS converting data type
 
Hence we can clearly see how the .NET Framework is converting the data type to a Common Type System, so it is a flexible communication among languages that are compliant with .NET Framework. I hope this article was helpful and it is easy to understand the concept of CTS and how using “ILDASM” we figured that the Common type System helps to bring the data types of all programming languages to a common type.