CLS
CLS
Value Type: A value type stores the data in memory allocated on the stack or inline in a
structure. This category of Type holds the data directory. If one variable's value is copied to
another, both the variables store data independently. It can be of inbuilt-in types, user-defined,
or enumerations types. Built-in types are primitive data types like numeric, Boolean, char, and
date. Users in the source code create user-defined types. An enumeration refers to a set of
enumerated values represented by labels but stored as a numeric type.
Net Common Language Runtime
Reference Type: A Reference type stores a reference to the value of a memory address and is
allocated on the heap. Heap memory is used for dynamic memory allocation. Reference Type
does not hold actual data directly but holds the address of data. Whenever a reference type
object is made, it copies the address and not actual data. Therefore two variables will refer to the
same data. If data of one Reference Type object is changed, the same is reflected for the other
object. Reference types can be self-describing types, pointer types, or interference types. The
self-describing types may be string, array, and class types that store metadata about themselves.
3. Garbage Collection:
Garbage Collector is a component of CLR that works as an automatic memory manager. It helps
manage memory by automatically allocating memory according to the requirement. It allocates heap
memory to objects. When objects are not in use, it reclaims the memory allocated to them for future
use. It also ensures the safety of objects by not allowing one object to use the content of another
object.
4. Just in Time (JIT) Compiler:
JIT Compiler is an important component of CLR. It converts the MSIL code into native code (i.e.,
machine-specific code). The .NET program is compiled either explicitly or implicitly. The developer or
programmer calls a particular compiler to compile the program in the explicit compilation. In implicit
compilation, the program is compiled twice. The source code is compiled into Microsoft Intermediate
Language (MSIL) during the first compilation process. The MSIL code is converted into native code in
the second compilation process. This process is called JIT compilation. There are three types of JIT
compilers -Pre, Econo, and Normal. Pre JIT Compiler compiles entire MSIL code into native code before
execution. Econo JIT Compiler compiles only those parts of MSIL code required during execution and
removes those parts that are not required anymore. Normal JIT Compiler also compiles only those
parts of MSIL code required during execution but places them in cache for future use. It does not
require recompilations of already used parts as they have been placed in cache memory.