Common Language Specification:
It is a set of the programming rules which every .NET language must follow.
CLS is used so that the code written in one language is interoperable with the code written in another language. The different .NET languages code is compiled into MSIL Code. CLS defines the infrastructure for the MSIL Code. The CLR processes the MSIL code and help in its execution. This ensures the language interoperability.
EXAMPLES OF CLS:
1)Common set of data types for all the languages( CTS)
Int32 datatype is implemented as int in C# and as integer in VB.NET
2)Interfaces cannot have static methods.It applies to all the .NET languages.
The Types which follow the CLS rules are also called as CLS Compliant types.
CLS compliant languages:
Use of CLS:
A class written in VB.NET can be used in C# and vice-versa.
For the complete list of CLS features, please visit this link.
Asked In: Many Interviews |