Lecture #01 Introduction to Dot NET
#Introduction to Dot NET, #.NET, #CLR, #CTS, #IL, #MSIL, #CIL
What is .NET Framework?
What is IL?
What is CIL?
What is MSIL?
What is CTS?
What is CLR?
https://www.youtube.com/c/newitworld
8. .NET Architecture …
.NET architecture is:
multi-language
cross-platform
based on the CLR, FCL, and JIT technology
.NET components are packaged as assemblies
10. Languages Supported by .NET
Over 35 languages are supported now
C#, VB, Jscript, Visual C++
Perl, Python, Smalltalk,
Cobol, Haskell, Mercury, Eiffel,
Oberon, Oz, Pascal,
APL, CAML, Scheme, etc.
11. Common Type System (CTS)
• A specification for how types are
defined and how they behave.
• no syntaxspecified
• A type can contain zero or more
members:
• Field
• Method
• Property
• Event
12. Common Type System (CTS)
CTS is a formal specification that describes
how a given type must be defined for CLR
• CTS Class Type
• CTS Structure Type
• CTS Interface Type
• CTS Enumeration type
• CTS Delegate type
13. CTS Class Type
• Same as C++ class
• Can contain members: methods,
properties, events, etc.
• Support for abstract members that
define a polymorphic interface for
derived classes
• Multiple inheritance is not allowed
14. CTS Class Characteristics
• "sealed"? – sealed classes can't function as
base classes
• Implement any interfaces? – An
interface is a collection of abstract
members
• Abstract or Concrete? – Abstract classes (to
define common behaviors for derived) can't be
created directly but concrete classes can.
• Visibility? – visibility attribute to know
whether external assemblies can use it.
15. CTS Structure types
Same as C/C++
Derived from a common base class
System.ValueType
CTS Enumeration type
To group name/value pairs under a
specific name Default Storage:
System.Int32 (could be Changed)
16. CTS Interface types
CTS Delegate type
• Same as pure abstract class of C++
• A description of work that a derived
class can perform
• Similar to a class, but can never be
instantiated
• Same as C's function pointer
(System.MulticastDelegate)
• Useful for event handling (ASP .NET)
17. CTS Data Types
.NET Base Type C# Type
System.Byte Byte
System.SByte sbyte
System.Int16 short
System.Int32 int
System.Int64 long
System.UInt64 ulong
System.Single float
System.Double double
System.Object object
System.String string
System.Boolean bool
18. CLS Compliance
C# Type CLS Compliance
byte Yes
sbyte No
short Yes
int Yes
long Yes
ulong No
float Yes
double Yes
object Yes
string Yes
char Yes
19. Common Language Runtime
A common runtime for all .NET
languages
Common type system
Common metadata
Intermediate Language (IL) to native code
compilers
Memory allocation and garbage collection
Code execution and security
20. Common Language Runtime
Execution Engine
Compiles Microsoft Intermediate
Language (MSIL) into nativecode
Handles garbagecollection
Handles exceptions
Enforces code accesssecurity
Handles verification
Managed v.Unmanaged Code
21. CLR Execution Model
Source
code
VB C# C++
Compiler Compiler Compiler
Assembly
IL Code
Assembly
IL Code
Assembly
IL Code
Common Language Runtime
JIT Compiler
Native Code
Operating System Services
Managed
code
Unmanaged
Component
22. Advantages of CLR
• Support for developer services (debugging)
• Interoperation between managed code and
unmanaged code (COM,DLLs).
• Managed code environment
• Improved memory handling
• Improved “garbagecollection”
23. Advantages of CLR
• JIT allows code to run in a protected environment
as managed code.
• JIT allows the IL code to be hardware
independent.
• CLR also allows for enforcement of code
access security.
• Verification of type safety.
25. Dot Net Namespaces
• MFC, Java, VB 6.0 have predefined set of
classes; C# doesn't
• C# uses namespace concept
• Any language targeting the .NET runtime
makes use of the same namespaces and
same types as C#
• System is the root namespace
26. Sample .NET namespaces
System
primitive types, garbage
collection, etc
System.Collections Container objects: ArrayList, Queue,
etc.
System.Data
System.Data.Common
System.Data.OleDb
System.Data.SqlClient
For Database manipulations ADO .NET
System.IO file IO, buffering, etc.
System.Drawing
System.Drawing.2D
GDI+ primitives, bitmaps, fonts, icons, etc.
System.Threading Threads
27. Common Data Types
CLR provides a set of primitive types that all
languages must support.The datatypes
include:
Integer—three types 16/32/64bits
Float—two types: 32/64 bits
Boolean and Character
Date/time and Time span
The primitive types can be collected into
Arrays
Structures
Combination of the two
28. Common Language Specification (CLS)
Not all languages support all CTS types and features
C# is case sensitive, VB.NET is not
C# supports pointer types (in unsafe mode),
VB.NET does not
C# supports operator overloading, VB.NET does not
CLS was introduced to promote language
interoperability
vast majority of classes within FCL are CLS-compliant
30. Base Class Library @ FCL
Unified Classes
Web Classes (ASP.NET)
Controls, Caching, Security, Session, Configuration etc
System Classes
Collections, Diagnostics, Globalization, IO, Security,
Threading Serialization, Reflection, Messaging etc
Data (ADO.NET)
ADO, SQL,Types etc
Drawing Classes
Drawing, Imaging, Text, etc
Windows Forms
Design, Cmpnt Model etc
XML Classes
XSLT, Path, Serialization etc
31. Framework Class Library @ BCL
Single consistent set of object oriented class
libraries to enable building distributed web
applications (Unified Classes)
Built using classes arranged across logical
hierarchical namespaces
Work with allCLR languages