Wednesday, May 29, 2013

CTS (Common Type System) & MSIL

Common Type System is the part of .NET Framework built in with CLR which is responsible for defining, managing different language's operation supported by .NET Framework. CTS are responsible for cross language Integration (Means you can have a dll which is written in C# and to be used in VB.Net application) and Type Safety. It enforces a set of rules that a programming language must follow.


Types of CTS (Common Type System)

The common type system supports two general categories of types:

1. Value types

Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in, user-defined or enumerations types.

2. Reference types

Reference types stores a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointers types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types are user-defined classes, boxed value types, and delegates.



CTS, much like Java, define every data type as a Class. Every .NET compliant language must stick to this definition. Since CTS defines every data type as a class; this means that only Object-Oriented (or Object-Based) languages can achieve .NET compliance.


Microsoft Intermediate Language (MSIL)


A .NET programming language (C#, VB.NET, J# etc.) does not compile into executable code; instead it compiles into an intermediate code called Microsoft Intermediate Language (MSIL). As a programmer one need not worry about the syntax of MSIL - since our source code in automatically converted to MSIL. The MSIL code is then send to the CLR (Common Language Runtime) that converts the code to machine language which is then run on the host machine. MSIL is similar to Java Byte code. A Java program is compiled into Java Byte code (the .class file) by a Java compiler, the class file is then sent to JVM which converts it into the host machine language.

No comments:

Post a Comment