+ All Categories
Home > Documents > Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program...

Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program...

Date post: 20-Jan-2016
Category:
Upload: hollie-higgins
View: 215 times
Download: 2 times
Share this document with a friend
29
Introduction to .NET Framework Po Feng, Tsai
Transcript
Page 1: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Introduction to .NET Framework

Po Feng, Tsai

Page 2: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

How a program is composed and executed A program

Written by you but executed by a machine (computer)

For programmers C,C++,Fortran,Basic

For machines Architecture dependent instruction set (in bi

nary forms) Translation is required

Page 3: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

How a program is composed and executed

Source Codes

Compiler

Assembler Object Codes

Linker

Loader

Assembly Codes

Hardware Architecture

Page 4: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Problems for a programmer

Platform dependent Windows ? Linux ?

Architecture dependent X86 ? ARM? PPC?

Interfacing with each others An isolated virtual framework layer

Page 5: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The .NET Framework To provide a convenient and united develo

pment and execution environment C#, VB.NET, C++.NET & Jscript.NET CLR (Common Language Runtime) FCL (framework class library)

Languages integration CTS (Common Type System) CLS (Common Language Specification) CLR

Page 6: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The .NET Framework Framework class library

Lower level: (Base class library) Core data type (integer, string, float, object) Fundamental constructs (collection, I/O …) Access to resources (Networking, file system…) Interface to core execution (Threading, debugging

…) Upper level:

SQL ADO.NET XML Web services

Page 7: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The .NET Framework

Page 8: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Compilation

Source codes are compiled into MSIL (MS Intermediate Language) for the first step

Metadata is used to keep the content information, such as parameters, methods, of the file

Page 9: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Execution CLR is the execution engine of .NET

framework application Virtual machine

It manages the following services Code management Memory management Conversion IL into native code Exception handling Debugging

Page 10: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Compilation & Execution

Page 11: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

JIT (Just In Time)

Very popular technique used in various virtual machines Machine codes are generated Fast Compiles as needed

Page 12: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Introduction to C#

Po Feng, Tsai

Page 13: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Getting started Visual C# 2005 Express

http://www.microsoft.com/taiwan/vstudio/express/visualcsharp/

System Requirements: Processor Minimum: 600 megahertz (MHz) Penti

um processorRecommended: 1 gigahertz (GHz) Pentium processor

RAM Minimum: 192 megabytes (MB)Recommended: 256 MB

Hard Disk: Up to 1.3 GB of available space may be required

Page 14: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

About C#

C# is announced in July 2000 C# includes the support for

structured, component-based, object-oriented programming Very easy to use Modern programming

Page 15: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Example 1: HelloWorld

In the console window:

Hello World

Page 16: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The Class

A type defines a thing including its properties and behaviors A class is used to define a new type Blueprints

Page 17: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The Method

Behaviors are defined by methods A method is a function owned by your cla

ss Defines what you can do or how it behav

es Usually you can tell what it is for from its nam

e WriteLine()

Page 18: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The Method

Declare a method Keyword: void

The program entry function Main() The program ends when Main() exits

Page 19: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The comments

You can add your own comments by // /* ……… */ /// (used by Visual Studio)

Page 20: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Namespace Tremendous number of types of the .NET Framewo

rk Class Library Each class in C# must have a unique name

Name collision Example (two engineers)

Jim: Science.software.engineer Charlotte: transportation.train.engineer System.Console.WriteLine();

Keyword: using using System; using System.Console; (does not compile !)

Page 21: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Console object

This is a console program No GUIs

Monitor is managed by an Console object It has many behaviors (methods)

WriteLine() Write()

Console.WriteLine()

Page 22: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The Dot operator ( . )

You can use the dot operator to access a method (or data) of a class or object

You can use the dot operator to specify the sub-namespace

Please keep in mind: C# is case-sensitive

Page 23: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

The static keyword

It is used to indicate that you can invoke Main() without first creating an object of type HelloWorld

This issue will be covered in later sections

Page 24: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Developing the HelloWorld Console mode (start cmd)

Need .NET Framework SDK csc HelloWorld

Use Visual Studio .NET (Integrated Development Environment)

Page 25: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Using VS .NET

File New Project Select “Console Application”

Page 26: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Using VS .NET

Page 27: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Compile & Run

Compile Build Build Solution Ctrl+shift+B

Run Debug Start Without Debugging F5 (debug) or Ctrl-F5

Page 28: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

HelloWorld.exe Contains op-codes written in MSIL Read-only segment

Inserted with standard win32 executable header

Jumps to the JIT compiler JIT compiler

Generating native instructions (like a normal exe file)

Page 29: Introduction to.NET Framework Po Feng, Tsai. How a program is composed and executed A program Written by you but executed by a machine (computer) For.

Recommended