Please enable Javascript to correctly display the contents on Dot Net Tricks!

Understanding Relationship Between CTS and CLS

  Author : Shailendra Chauhan
Posted On : 18 Oct 2013
Total Views : 174,086   
Updated On : 26 Sep 2016
 

CTS and CLS are parts of .NET CLR and are responsible for type safety with in the code. Both allow cross language communication and type safety. In this article I would like to expose the relationship between these two.

CTS

CTS stands for Common Type System. It defines the rules which Common Language Runtime follows when declaring, using, and managing types. The common type system performs the following functions:

  1. It enables cross-language integration, type safety, and high-performance code execution.

  2. It provides an object-oriented model for implementation of many programming languages.

  3. It defines rules that every language must follow which runs under .NET framework. It ensures that objects written in different .NET Languages like C#, VB.NET, F# etc. can interact with each other.

normal jiit

CLS

CLS stands for Common Language Specification and it is a subset of CTS. It defines a set of rules and restrictions that every language must follow which runs under .NET framework. The languages which follows these set of rules are said to be CLS Compliant. In simple words, CLS enables cross-language integration.

For example, one rule is that you cannot use multiple inheritance within .NET Framework. As you know C++ supports multiple inheritance but; when you will try to use that C++ code within C#, it is not possible because C# doesn’t supports multiple inheritance.

One another rule is that you cannot have members with same name with case difference only i.e. you cannot have add() and Add() methods. This easily works in C# because it is case-sensitive but when you will try to use that C# code in VB.NET, it is not possible because VB.NET is not case-sensitive.

Why CTS is Called Common Type System?

In .NET, every Data Type is internally represented by a class or structure. All the classes and structures related to Data Types are collectively known as CTS. As you know every language provides its own keywords for Data Types but internally all the languages which run under .NET framework use the classes and structures available in CTS.

For example, C# has int Data Type and VB.Net has Integer Data Type. Hence a variable declared as int in C# or Integer in vb.net, finally after compilation, use the same structure Int32 from CTS.

All the structures and classes available in CTS are common for all .NET Languages and purpose of these is to support language independence in .NET. Hence it is called CTS.

What do you think?

I hope, you have enjoyed the article about CTS and CLS. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.



Free Interview Books
 
COMMENTS (1)
Jee Reply

Hi From this article what i understood is, CTS is more of like lookup where it maintains common data type for different .net languages and finally the common data type stored in CTS will be used when .Net code is compiled to IL. Why do we say it defines rules for CLR? and also i dont understand why are we saying CLS is subset of CTS? We can say CLS defines the rule for CLR as it actually gives rules for the developers to strict to particular common standards.

5 AUG
ASP.NET MVC with Angular4 Development (Online)

10:30 Am to 12:30 PM IST (+ 5:30 GMT)

Know More
3 AUG
ASP.NET Core with Angular4 Development (Online)

07:00 AM - 9:00 AM IST(+5:30 GMT)

Know More
29 JUL
Angular2 and Angular4 Development (Online)

08:00 AM - 10:00 AM IST(+5.30 GMT)

Know More
29 JUL
ASP.NET MVC with Angular4 Development (Classroom)

09:30 AM - 11:00 AM IST (+5:30GMT)

Know More
29 JUL
Xamarin Forms : Build Cross-platform Apps (Classroom)

09:00 AM - 11:00 AM IST(+5:30 GMT)

Know More
26 JUL
ASP.NET MVC with Angular4 Development (Online)

07:00 AM - 09:00 AM IST(+5.30 GMT)

Know More
26 JUL
ASP.NET MVC with Angular4 Development (Online)

07:00 AM - 09:00 AM IST(+5.30 GMT)

22 JUL
MEAN Stack 2 Development (Classroom)

04:00 PM - 05:30 PM IST(+5:30GMT)

20 JUL
Hadoop Development cum Administration (Online)

07:00 AM - 09:00 AM IST(+5:30 GMT)

17 JUL
NodeJS with Angular4 Development (Online)

08:00 PM - 09:30 PM IST(+5.30 GMT)

15 JUL
ASP.NET MVC with Angular4 Development (Online)

03:30 PM - 05:30 PM IST(+5.30 GMT)

1 JUL
ASP.NET MVC with Angular4 Development (Classroom)

08:00 AM - 09:30 AM IST

1 JUL
MEAN Stack 2 Development (Classroom)

11:00 AM - 12:30 PM IST(+5:30 GMT)

30 JUN
Xamarin Forms : Build Cross-platform Apps (Online)

09:30 PM - 11:00PM IST(+5:30GMT)

6 JUN
ASP.NET MVC with Angular4 Development (Online)

09:00 PM-11:00 PM IST(+5.30 GMT)

20 MAY
NodeJS with Angular4 Development (Classroom)

05:00 PM - 07:00 PM

2 MAY
ASP.NET Core Development (Online)

07:00 AM - 09:00 AM IST(+5.30 GMT)

BROWSE BY CATEGORY
 
 
LIKE US ON FACEBOOK
 
+