2.2.1.
The role of the Common Language Runtime
-
A runtime system is used to support the execution of programs
-
.NET provides a runtime system that is used by all .NET
languages
-
Microsoft are providing .NET compilers for:
-
Managed C++
-
JScript
-
Visual Basic.NET
-
J#
-
C#
-
Others are providing .NET compilers for:
-
COBOL
-
Eiffel
-
Fortran
-
Haskell
-
ML
-
Perl
-
Python
-
Scheme
-
Smalltalk
-
...
-
A .NET compiler writer can rely on the CLR:
-
to create new types;
-
to create and initialize objects;
-
to track references to objects
and provide garbage collection;
-
to handle the calling of methods;
-
to manage the access to array elements;
-
to provide support for exceptions;
-
...
-
A .NET compiler generates code in
an intermediate language called
MSIL.
-
A platform
needs a
CLR engine
in order to run a file containing MSIL instructions.
-
There are CLR engines for most Windows platforms.
-
A project called
Mono
is building an open-source implementation of the .NET Framework.
2.2.2.
The Common Type System
-
The CLR also includes a
Common Type System
(CTS).
-
The
Common Language Specification
(CLS)
defines the aspects of the CTS
that is supported by all .NET languages.
-
CLS says that each language must provide:
-
value types
-
simple types,
-
structure types,
-
enumeration types
-
reference types
-
class types,
-
interface types,
-
array types,
-
delegate types
2.2.3.
The simple types
There is a set of simple types some of which must be
provided.
They are:
|
size
|
C#
|
Managed C++
|
Visual Basic.NET
|
System.Boolean
|
8
|
bool
|
bool
|
Boolean
|
System.Byte
|
8
|
byte
|
char
|
Byte
|
System.Int16
|
16
|
short
|
short
|
Short
|
System.Int32
|
32
|
int
|
int
or
long
|
Integer
|
System.Int64
|
64
|
long
|
__int64
|
Long
|
System.Single
|
32
|
float
|
float
|
Single
|
System.Double
|
64
|
double
|
double
|
Double
|
System.Char
|
16
|
char
|
__wchar_t
|
Char
|
System.Decimal
|
128
|
decimal
|
System::Decimal
|
Decimal
|