Components Of .NET Framework

Common Type System (CTS)

 
CTS is basically a standard that specifies how types are declared, used, and managed in the common language runtime and it is intended to allow programs written in different programming languages to easily share information. It establishes a framework that helps enable cross-language integration, enforces type security, and define rules which languages must follow to ensure that objects written in different languages can interact with each other.
 
Now following these guidelines, C# is a very type-safe language. It's strongly typed because type rules are very strict e.g you cannot call a function that accepts an integer with a floating-point number unless you perform the explicit conversion.
 

Common Language Specification (CLS)

 
CLS is a subset of CTS, it specifies a set of rules that needs to be satisfied by all language compilers targeting CLR. CLS are mere guidelines and restrictions that a language should follow so that they can communicate with other .NET languages in a smooth manner.
 
For example, C# does not allow multiple inheritances but c++ does, therefore c++ code cannot be used inside C# because it is not a CLS compliant language.
 

Common Language Runtime (CLR)

 
The .NET framework consists of CLR plus a set of libraries. The two terms BCL (Base Class Library) and FCL (Framework Class Library) will encounter often being used interchangeably, however, there is a slight difference between the two. BCL consists of mscorlib(Microsoft Core Library), system, and possibly other additional assemblies. However, it does not contain ASP.NET, ADO.NET and WinForms, and other such classes/namespaces that provide additional functionality.
 
FCL is BCL plus everything that ships as the .Net framework. Therefore, FCL is the entire framework whereas BCL is just the core libraries.
 
The c# code or any of the .NET languages code gets compiled into CIL(Common Intermediate Language) which is often called managed code. And when finally CLR loads an assembly, it converts the IL into the native code of the machine. This conversion from IL to native code is done by CLR's JIT(Just In Time) compiler.
 

JIT compiler

 
JIT compiler converts the appropriate instruction to native code for execution just before the function is called and hence the managed code or IL is compiled only when it is needed. CLR provides various JIT compilers and each works on a different architecture depending on OS. This is the reason why Microsoft Intermediate Language can be executed on different OS without the need of rewriting the code specific to that OS.
 

C# relationship with CLR

 
Technically, C# is independent of CLR, however, it depends on a runtime equipped with a host of features such as:
  1. Automatic memory management
  2. Exception Handling, etc.
CLR offers automatic memory management, it has a garbage collector that executes as part of our program, reclaiming the memory of objects that are no longer needed. C# type system maps closely to the CLR type system because both share the same definitions for predefined types.
 
So, it is evident that the design of C# maps closely with the design of Microsoft's CLR provides the above-mentioned runtime features.
 
Above was a brief overview of all the terms you'll hear while listening to a .NET or even C# discussion. Hopefully, now you'll know the meaning behind them.


Similar Articles