Thursday, January 8, 2009

What is CTS (Common Type System)

In order that two language communicate smoothly CLR has CTS (Common Type System).
Example:In VB you have “Integer” and in C++ you have “long” these datatypes are not compatible so the interfacing between them is very complicated. In order to able that two different languages can communicate Microsoft introduced Common Type System. So “Integer” datatype in VB6 and “int” datatype in C++ will convert it to System.int32 which is datatype of CTS. CLS which is covered in the coming question is subset of CTS.

Understanding Common Type System in .Net Framework
For example, an integer variable in C# is written as int, whereas in Visual Basic it is written as integer. Therefore in .Net Framework you have single class called System.Int32 to interpret these variables. Similarly, for the ArrayList data type .Net Framework has a common type called System.Collections.ArrayList. In .Net Framework, System.Object is the common base type from where all the other types are derived.

This system is called Common Type System. The types in .NET Framework are the base on which .NET applications, components, and controls are built. Common Type System in .Net Framework defines how data types are going to be declared and managed in runtime. The Common Type System performs the following functions:
  • Automatically adapts itself in a framework that enables integration of multiple languages, type safety, and high performance code execution.
  • Provides an object-oriented model.
  • Standardizes the conventions that all the languages must follow.
  • Invokes security checks.
  • Encapsulates data structures.
There are two general types of categories in .Net Framework that Common Type System support. They are value types and reference types. Value types contain data and are user-defined or built-in. they are placed in a stack or in order in a structure. Reference types store a reference of the value’s memory address. They are allocated in a heap structure. You can determine the type of a reference by the values of self-describing types. Reference types can be categorized into self-describing types, pointer types, or interface types.

Note: If you have undergone COM programming period interfacing VB6 application with
VC++ application was a real pain as the datatype of both languages did not have a
common ground where they can come and interface, by having CTS interfacing is smooth.

Suggested reading in Basic .NET FrameWork
For more detail about common type systemt please knock MSDN.



0 Responses to "What is CTS (Common Type System)"

Copyright 2009 All Rights Reserved Shakti Singh Dulawat