What is CTS (Common Type System) in .NET?
CTS is another standard developed by Microsoft to integrate different language under .NET. We can say that CTS is a subset of CLS.
.
We know that in .NET different assembly can be written in different language. And these assemblies can execute together.
.
Have you ever think how these assemblies can communicate with each other? Because each language have different data types, different memory size.
.
This is place where CTS comes in picture.
.
We have already discuss that .NET Framework understand only MSIL. And every source code is converted into MSIL whether we have use any language
.
In .NET each data types of language are mapped to data types of MSIL or types defined by CTS. So at time of converting in MSIL code each data types are converted in corresponding type defined in CTS.
.
For example Integer of VB.NET and int of C# both are mapped to Int32 type of CTS. So at the time of converting in MSIL both this data types will be converted in Int32 type. Now communication between two language are possible.
.
Following are table of C# data type and their mapped CTS Type in .NET
.
C# Data Types | Mapped CTS Type | Size in Bytes |
byte | Byte | 1 |
sbyte | SByte | 1 |
short | Int16 | 2 |
ushort | UInt16 | 2 |
int | Int32 | 4 |
unit | UInt32 | 4 |
long | Int64 | 8 |
ulong | UInt64 | 8 |
float | Single | 4 |
double | Double | 8 |
bool | Boolean | 1 |
char | Char | 2 |
decimal | Decimal | 12 |