Common Type System (CTS) in .NET

CTS stands for Common Type System. The data type that can be used by managed code of CTS. CTS deals with the data type and one language data type cannot be understandable by other languages but the .NET Framework language can understand all the data types.

The CTS performs the following functionality :

  1. It enables cross-language integration, type safety, and high-performance code execution.
  2. It provides an object-oriented model for the implementation of many programming languages.
  3. In C# has an int data type and VB.NET has an Integer data type. Hence a variable declared as an int in C# and Integer in VB.NET uses the same  structure int32 from CTS

Let’s start with an example,

Step-1 Create a class library project and use the C# programming language

public class Calculator
{
  public int Calculate()
  {
    int a = 10, b = 20;
    int c = a + b;
    return c;
  }
}

Step-2 Create a VB class library project

Public Class Calculator
  Public Function Calculate() As Integer
    Dim a As Integer = 10
    Dim b As Integer = 10
    Dim c As Integer
      c = a + b
      Return c
  End Function
End Class

Common Type System Diagram :

I hope the concept of the Common Type System is clear.

Submit a Comment

Your email address will not be published.

Subscribe

Select Categories