Professional Documents
Culture Documents
Net Fundamentals>
C3: Protected
My Academy
Credential
Information:
Version and
Date:
V1.1
Confidential
Icons Used
Questions
Tools
Coding
Standard
s
Test Your
Understandi
ng
Demonstrati
on
A
Welcome
Break
2007, Cognizant Technology Solutions
Hands on
Exercise
Referenc
e
Contacts
Confidential
Introduction
Introduction:
The Microsoft. NET strategy was presented by Microsoft officials
to the rest of the world in June 2000:
.NET is Microsoft's new Internet and Web strategy
.NET is NOT a new operating system
.NET is a new Internet and Web based infrastructure
.NET delivers software as Web Services
.NET is a framework for universal services
.NET is a server centric computing model
.NET will run in any browser on any platform
.NET is based on the newest Web standards
Confidential
Objectives
Microsoft .Net aims to reduce the cost of
software development by creating re-useable code that can be
used by all applications in the environment, regardless of
operating system or programming language. In this session
you
will get an understanding of the following:
.net Fundamentals
CLR
Memory Management
Classes and Ojjects
Access modifiers
Constructors and Destructors
2007, Cognizant Technology Solutions
Confidential
Framework
.Net Framework
Consists of two main components
.Net Framework Class Library
CLR
.Net Framework Class Library
Provides the types that are common to all
languages
These types can be used to develop different kinds
of applications, such as Console application,
Windows and Web Forms, and XML Web Services
Confidential
CLR(Common Language
Runtime)
CLR(Common Language Runtime)
CLR is the execution environment of .NET
Code built to depend on CLR is MANAGED CODE
Loads the IL Code into runtime
Compile the IL code into native code
Execute and manage the code
Enforce security and type safety
Confidential
CLR(Common Language
Runtime)
CLR provides
memory management
garbage collection
tightened security
ease of deployment and maintenance
effective debugging facilities
multi language integration
Replacement of DLLs with versioned assemblies
Confidential
Learn How
.Net Framework
Microsoft Intermediate Language
Contains CPU independent set of instructions
Meta Data
Defines the type that the code contains and references to
other types that the code uses at run time
Confidential
Learn How
Common Type System
Each language has its own set of types
Type conversion in inter language communication is a
pain
Errors usually goes unnoticed during compilation
Results in runtime errors
Confidential
10
Memory Management
Memory Management
Allocating Memory
Releasing memory
Implementing Finalizes
Confidential
11
Memory Management
Allocating Memory
CLR administers area of Heap - Managed Heap
Takes full control of object space allocation
As objects created, memory allocated linearly
this allows for fast allocation
Confidential
12
Memory Management
Releasing Memory
GC(Garbage Collector) periodically releases memory
GC considers all unreachable objects on the managed
heap as garbage
GC performs the memory copy function to compress
the objects in the managed heap.
GC uses the highly optimized mechanism
GC cannot clean the system resources used by
managed objects
Explicitly called by GC.Collect();
Confidential
13
Finalizers
Implementing Finalizers
Contains the clean up code that is executed before the
object is
garbage collected
Dispose and Finalize methods
GC.SuppressFinalize()
Confidential
14
.Net Assembly
Manifest
Identity of assembly
Security declarations
Dependencies
Exposed types/resources
Module
Module
Metadata
Metadata
IL
IL
Type
Method
Properties
Fields
Type
Method
Properties
Fields
unit of deployment
2007, Cognizant Technology Solutions
Type
Method
Properties
Fields
Type
Method
Properties
Fields
dll or
exe
Confidential
15
Assembly Types
Assembly is Building blocks of programming
in .Net
Private Assemblies
the default
only intended for use by one application
if several applications use, each will have a copy
(not the intent)
Shared Assemblies
this is intended for use by multiple applications
name must be unique so it does not collide
place in the global assembly cache
2007, Cognizant Technology Solutions
Confidential
16
Assembly
Assembly
Assembly manifest contains information about the
identity of an
assembly
Name, version, culture and strong name information of
an
assembly determine its identity
Assembly should have a strong name to access it
globally. Only
strong named assemblies can be placed inside the
GAC
2007, Cognizant Technology Solutions
Confidential
17
Assembly
Metadata
Assembly carries information that describes it
Details about
classes
properties
methods
fields
execution and security needs
Confidential
18
Assembly
Manifest
Describes details about the assembly
version
security
scope
resources
classes
types
dependencies
Stored either
as a Portable Executable (PE) file along with MSIL
or as stand along PE file with only the manifest info
Confidential
19
Namespace
Confidential
20
Namespace
Namespaces represent the single organizing principle
used to
group all the different types in the class library
Every piece of code in .Net exists inside a class. In
turn, every
class exists inside a namespace.
When you import the namespace, you dont need to
type the fully
qualified name.
Confidential
21
Namespace
Web System.Web.UI
Web Services System. Web.Services
Database System.Data
Example
namespace CTS
{
namespace Training
{
public class Classroom {}
}
Confidential
22
Namespace
Project, by default, has root namespace
Any namespace you create becomes its child
May not be desirable
Confidential
23
properties (attributes)
behavior
relationship to other Objects
Semantics
Blueprints of Objects
Object is a Concept, abstraction, or thing with crisp
Confidential
24
enclosing class
Much like concept of inner class in Java than nested
class in C++
Useful to
implement code that needs to be modularized but not (re)usable
outside a class
useful to implement interfaces
Some times even multiple implementations of same interface
Confidential
25
}
2007, Cognizant Technology Solutions
Confidential
26
Access modifiers
Access modifiers
Private (default)
public
protected
internal
Protected internal
Confidential
27
Access modifiers
Classes
Abstract classes
The abstract modifier is used to indicate that a class is
Sealed classes
The sealed modifier is used to prevent derivation from a
class
Confidential
28
Access modifiers
abstract class A
{
public abstract void F();
}
abstract class B: A
{
public void G() {}
}
class C: B{
public override void F()
{
// actual implementation of F }
}
2007, Cognizant Technology Solutions
Confidential
29
Access modifiers
sealed class TestFinal
{
private int SomeData;
public void SomeMethod()
{
}
}
class ExtendFinal: TestFinal
{
}
Confidential
30
Constructors
Constructors
Object Initialization
Guarantees object is in a valid state upon
creation
Constructor called automatically when object
created
Constructor has the same name as the class in
Confidential
31
Constructors
Type of Class Constructor
Instance
Private
Static
Confidential
32
Destructors
Destructors are used to destruct instances of classes.
A class can only have one destructor.
Destructors cannot be called. They are invoked
automatically.
A destructor does not take modifiers or have
parameters.
Confidential
33
Summary
The Microsoft .NET Framework is a software component which can be added to the Microsoft Windows
operatingsystem.
It provides a large body of pre-coded solutions to common program requirements, and manages the
execution of programs written specifically for the framework. The .NET Framework is a key Microsoft
offering, and is intended to be used by most new applicationscreated for the Windowsplatform.
The pre-coded solutions in the namespaces form the framework's class library and cover a large range
ofprogrammingneeds in areas including the user interface,dataaccess, cryptography, numeric
algorithms, and network communications. The functions of the class library are used by programmers who
combine them with their own code to produce applications.
Programs written for the .NET Framework execute in a software environment that manages the program's
runtime requirements. This runtime environment, which is also a part of the .NET Framework, is known as
the Common Language Runtime (CLR). The CLR provides the appearance of an application virtual machine,
so that programmers need not consider the capabilities of the specific CPU that will execute the program.
The CLR also provides other important services such as security guarantees, memory management, and
exception handling.
The class library and the CLR together compose the .NET Framework. The framework is intended to make it
easier to develop computer applications and to reduce the vulnerability of applications and computers to
security threats. First released in 2002, it is included with Windows Server 2003 and Windows Vista, and
can be installed on most older versions.
Confidential
34
Disclaimer: Parts of the content of this course is based on the materials available from the
Web sites and books listed above. The materials that can be accessed from linked sites are
not maintained by Cognizant Academy and we are not responsible for the contents thereof.
All trademarks, service marks, and trade names in this course are the marks of the
respective owner(s).
2007, Cognizant Technology Solutions
Confidential
35