dot net fundamentals

36
<.Net Fundamentals> C3: Protected

Upload: jagannadh-birakayala

Post on 25-Dec-2015

27 views

Category:

Documents


4 download

DESCRIPTION

Dot Net Fundamentals

TRANSCRIPT

Page 1: Dot Net Fundamentals

<.Net Fundamentals>

C3: Protected

Page 2: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 2

About the Author

Created By: My Academy

Credential Information:

<Enter the technical qualification and experience of the author> Also mention project details and COE details.

Version and Date:

V1.1

Page 3: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 3

Icons Used

Questions

Contacts

Reference

Demonstration

Hands on Exercise

Coding Standards

Test Your Understanding

Tools

A Welcome Break

Page 4: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 4

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

Page 5: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 5

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

Page 6: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 6

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

Page 7: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 7

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

Page 8: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 8

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

Page 9: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential

Learn How

.Net Framework

Microsoft Intermediate LanguageContains CPU – independent set of instructions

Meta DataDefines the type that the code contains and references to other types that

the code uses at run time

Portable Executable File

9

Page 10: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 10

Learn How

Common Type System

Each language has its own set of typesType conversion in inter language communication is a painErrors usually goes unnoticed during compilation

Results in runtime errors

CTS addresses thisOne set of types for all .NET languagesSystem.Object is the base type

Offers common set of methods for all types

Page 11: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 11

Memory Management

Memory Management

Allocating Memory

Releasing memory

Implementing Finalizes

Page 12: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 12

Memory Management

Allocating Memory

CLR administers area of Heap - Managed Heap

Takes full control of object space allocation

As objects created, memory allocated linearlythis allows for fast allocation

Page 13: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 13

Memory Management

Releasing MemoryGC(Garbage Collector) periodically releases memoryGC considers all unreachable objects on the managed heap as

garbageGC performs the memory copy function to compress the objects

in the managed heap.GC uses the highly optimized mechanismGC cannot clean the system resources used by managed objectsExplicitly called by GC.Collect();

Page 14: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 14

Finalizers

Implementing Finalizers

Contains the clean up code that is executed before the object is

garbage collected

Dispose and Finalize methods

GC.SuppressFinalize()

Page 15: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential

.Net Assembly

15

Manifest

Module

Metadata

IL

Type•Method

•Properties•Fields

Type•Method

•Properties•Fields

Module

Metadata

IL

Type•Method

•Properties•Fields

Type•Method

•Properties•Fields

•Identity of assembly•Security declarations

•Dependencies•Exposed types/resources

dll or exeunit of deployment

Page 16: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 16

Assembly Types

Assembly is Building blocks of programming in .NetPrivate Assemblies

the default

only intended for use by one application

if several applications use, each will have a copy (not the intent)

Shared Assembliesthis is intended for use by multiple applications

name must be unique so it does not collide

place in the global assembly cache

Page 17: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 17

Assembly

AssemblyAssembly 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

Page 18: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 18

Assembly

Metadata Assembly carries information that describes it Details about

classes properties methods fields execution and security needs

Metadata is piggybacked within the Assembly Always stays in synch with the code

Page 19: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 19

Assembly

ManifestDescribes 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

Page 20: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 20

Namespace

A namespace eliminates the problem of name collisionTwo persons can write two different classes with same nameNames are resolved using namespaceNS1.CLS1NS2.CLS1

Classes with same name, but from different namespaces

System is a well defined namespace from library of classes provided by .NET

several classes that provide widely used functionalities

Namespaces are words separated by periods

Page 21: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 21

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 don’t need to type the fully

qualified name.

Page 22: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 22

Namespace

Web – System.Web.UIWeb Services – System. Web.ServicesDatabase – System.DataExample

namespace CTS{

namespace Training{

public class Classroom {}}

}

Page 23: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 23

Namespace

Project, by default, has root namespace Any namespace you create becomes its child May not be desirable

You may want to remove the default root namespace Right click on Assembly name in Solutions Explorer, Properties

Page 24: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 24

Classes & Objects

Classes & Objects Group of Objects with similar

properties (attributes) behavior relationship to other Objects Semantics

Blueprints of Objects Object is a “Concept, abstraction, or thing with crisp boundary

& meaning for a problem.”

Page 25: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 25

Classes & Objects

Nested Classes A class may be written within an enclosing class If nested class is non-public, can’t be seen outside 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

Page 26: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 26

Classes & Objects

Example

using System;

class Hello

{public static int Main()

{Console.WriteLine("Hello World!");

return 0;

}

}

Page 27: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 27

Access modifiers

Access modifiers

Private (default) public protected internal Protected internal

Page 28: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 28

Access modifiers

Classes

Abstract classes The abstract modifier is used to indicate that a class is

incomplete and that it is intended to be used only as a base class.

Abstract classes represent concepts not real objects

Sealed classes The sealed modifier is used to prevent derivation from a

class

Page 29: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 29

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 }}

Page 30: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 30

Access modifiers

sealed class TestFinal{private int SomeData;public void SomeMethod(){}}class ExtendFinal: TestFinal{}

Page 31: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 31

Constructors

ConstructorsObject InitializationGuarantees object is in a valid state upon creation Constructor called automatically when object created

Constructor has the same name as the class in Java, C++ and C# languages

No return value

Page 32: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 32

Constructors

Type of Class Constructor Instance Private Static

Instance constructors are used to create and initialize instances. A private constructor is a special instance constructor. It is commonly used in

classes that contain static members only. A static constructor is used to initialize a class. It is called automatically to

initialize the class before the first instance is created or any static members

are referenced.

Page 33: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 33

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.

Page 34: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 34

Summary

The Microsoft .NET Framework is a software component which can be added to the Microsoft Windows

operating system. 

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 applications created for the Windows platform.

The pre-coded solutions in the namespaces form the framework's class library and cover a large range of programming needs in areas including the user interface, data access, 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.

Page 35: Dot Net Fundamentals

© 2007, Cognizant Technology Solutions Confidential 35

<RIO Name>: Source

http://www.academictutorials.com

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).

Page 36: Dot Net Fundamentals

You have successfully completed <RIO Name>

Click here to proceed