Difference between cts and cls

umarali1981 9,403 views 2 slides Aug 22, 2012
Slide 1
Slide 1 of 2
Slide 1
1
Slide 2
2

About This Presentation

This document provides difference between CTS and CLS


Slide Content

Difference between CTS and CLS
S.NoCTS CLS
1 Abbreviation:
CTS stands for Common Type
System
Abbreviation:
CLS stands for Common Language
Specification
2 Meaning:
It describes how types are
declared, used and managed in the
runtime and facilitates cross-
language integration, type safety,
and high performance code
execution.
The types defined by the CTS are
broadly classified into value types
and reference types. Value types
are those which themselves
contain data/methods/resources
represented by the type - like an
integer variable is a value type.
Reference types are those which
refer to value types and a pointer
or a reference is an example of
such a type. All types derive from
'System.Object' base type.
Meaning:
It is a specification that defines the
rules to support language integration in
such a way that programs written in
any language, yet can interoperate with
one another, taking full advantage of
inheritance, polymorphism,
exceptions, and other features. These
rules and the specification are
documented in the ECMA proposed
standard document.
3 Power of CTS:
CTS is a superset of the
CLS,i.e.,all .NET languages will
not support all the types in the
CTS.
Power of CLS:
CLS is a subset of the CTS which
all .NET languages are expected to
support.
4 Example:
“Integer” datatype in VB and
“int” datatype in C++ are not
compatible, so the interfacing
between them is very
complicated. In order that two
different languages can
communicate, “Integer” in VB6
and “int” in C++ will convert to
System.int32 which is datatype of
CTS.
(or)
Example:
A class written in C# can inherit from
a class written in VB.
So we can say that using this
specification (CLSCompliant attribute)
in our programs (written in any
language), the type is forced to
conform to the rules of CLS and
programs can interoperate with one
another, taking full advantage of
polymorphism, inheritance and other
features.

In c#, we will declare int i;
In vb, we will declare dim i as
integer
Basically Microsoft will convert
all this data types to the generic
data types. So, if we write code in
different languages that will
convert into language independent
code. This is called Common type
system(CTS).
And, further updates on difference between questions and answers, please visit my blog @
http://onlydifferencefaqs.blogspot.in/