1. Prof. Neeraj Bhargava
Pramod Singh Rathore
Department of Computer Science
School of Engineering & System Sciences,
MDS University Ajmer, Rajasthan, India
1
Type System
2. TYPE SYSTEM
The common type system defines how types are declared,
used, and managed in the runtime, and is also an important
part of the runtime's support for cross-language integration.
The common type system performs the following functions:
Establishes a framework that helps enable cross-language
integration, type safety, and high performance code
execution.
2
3. TYPE SYSTEM
Provides an object-oriented model that supports the
complete implementation of many programming languages.
Defines rules that languages must follow, which helps
ensure that objects written in different languages can
interact with each other.
3
4. Functions of the Common Type
System
To establish a framework that helps enable cross-language
integration, type safety, and high performance code
execution .
To provide an object-oriented model that supports the
complete implementation of many programming languages.
To define rules that languages must follow, which helps
ensure that objects written in different languages can
interact with each other.
4
5. Functions of the Common Type
System
The CTS also defines the rules that ensures that the data
types of objects written in various languages are able to
interact with each other.
The CTS also specifies the rules for type visibility and
access to the members of a type, i.e. the CTS establishes
the rules by which assemblies form scope for a type, and
the Common Language Runtime enforces the visibility
rules.
The CTS defines the rules governing type inheritance,
virtual methods and object lifetime.
Languages supported by .NET can implement all or some
common data types
5
6. Classification of Types
The common type system supports two general categories
of types, each of which is further divided into
subcategories:
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
(implemented by the runtime), user-defined, or
enumerations. For a list of built-in value types.
6
7. Classification of Types
Reference types
Mr. Sanjay Tejasvee(9251933560) MIT 402: .Net
Framework and Programming in ASP.Net
Reference types store a reference to the value's memory
address, and are allocated on the heap. Reference types
can be self-describing types, pointer types, or interface
types. The type of a reference type can be determined from
values of self-describing types. Self-describing types are
further
7
8. example shows the difference
between reference types and value
types
class Test
{
static void Main() {
int val1 = 0;
int val2 = val1;
val2 = 123;
Class1 ref1 = new Class1();
Class1 ref2 = ref1;
ref2.Value = 123;
Console.WriteLine("Values: {0}, {1}", val1, val2);
Console.WriteLine("Refs: {0}, {1}", ref1.Value, ref2.Value);
8