Tải bản đầy đủ (.ppt) (19 trang)

lập trình trên windows với microsoft® .net

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (583.68 KB, 19 trang )

Lập trình trên Windows
với Microsoft® .NET
Gi ng viên : H Hoàn Ki mả ồ ế

Gi i thi u Microsoft.Net .ớ ệ

Gi i thi u ngôn ng C# và các khái ni m c b n.ớ ệ ữ ệ ơ ả

L p trình h ng đ i t ng v i C#.ậ ướ ố ượ ớ

L p trình Winforms v i C#.ậ ớ

L p trình c s d li u v i ADO.Net .ậ ơ ở ữ ệ ớ
N i dung môn h c ộ ọ

Kh o sát ki n trúc .Net . ả ế

Xây d ng các ng d ng v i .Net .ự ứ ụ ớ

Các thành ph n trong .Net Framework.ầ

Vai trò c a CLR và IL .ủ
Gi i thi u Microsoft.NET.ớ ệ
Microsoft .NET Framework Architecture
Windows LINUX
Common Language Runtime
Framework Class Library
Common Language Specification
Microsoft
Visual Basic
®


.NET
C++ C#
Microsoft
JScript
®

Microsoft Visual Studio® .NET
XML Web
Services
Devices
Servers
User
Experiences
Developer
Tools
.NET Platform
.NET Framework
.NET Framework
Common Language
Common Language
Runtime
Runtime
Class Library
Class Library
Windows
Web Services
ADO.NET
Data Types
Visual Basic
Applications

Visual C#
Applications
Visual C++
Applications
Programming Services
.NET
Platform
Code
.NET
Platform
Code
Source code compiles
as MSIL
Source code compiles
as MSIL
JIT compiler produces
machine language
JIT compiler produces
machine language
One-stop Application
Development
Visual Studio .NET
Design
Design
Design
Design
Develop
Develop
Develop
Develop

Debug
Debug
Debug
Debug
Deploy
Deploy
Deploy
Deploy
Data Access
Data Access
XML Web
Services Tools
XML Web
Services Tools
Windows
Forms Tools
Windows
Forms Tools
Web Forms
Tools
Web Forms
Tools
Error
Handling
Error
Handling
Multiple
Languages
Multiple
Languages

Các đ c đi m c a Visual Studio .NETặ ể ủ
H tr l p trình đa ngôn ng .ổ ợ ậ ữ
Đ c l p v i h đi u hành (Platform ).ộ ậ ớ ệ ề
Xây d ng ng d ng nhanh chóng và d dàng.ự ứ ụ ễ
H tr xây d ng ng d ng cho nhi u thi t b .ổ ợ ự ứ ụ ề ế ị
Môi tr ng thi t k tr c quan .ườ ế ế ự
H ng đ n các ng d ng trên Internet (Webservice, WAP…)ướ ế ứ ụ
Microsoft Intermediate Language (MSIL)
Microsoft Intermediate Language (MSIL)
Common Language Specification
Common Language Specification
VB
VB
C++
C++
C#
C#
JScript
JScript
J#
J#
Common Language Runtime (CLR)
Common Language Runtime (CLR)
Just In-Time Compiler (JIT)
Just In-Time Compiler (JIT)
Operating System
Operating System
MSIL, JIT và CLR
Th c thi m t ch ng trình .Netự ộ ươ
C#

Code
C#
Compiler
Visual Basic
Code
Visual Basic
Compiler
COBOL
Code
COBOL
Compiler
IL
JIT
Compiler
Native
Code
.NET
source
code
Language
Compiler
MSIL
+
Metadata
Machine
code
Code
executed
CLR
1

st
Compilation
2
nd
Compilation
Th c thi các ch ng trình .NETự ươ
Microsoft Intermediate Language
.NET
source
code
Language
Compiler
MSIL
+
Metadata
Machine
code
Code
executed
CLR
MSIL
Helps Language
interoperability
IL is not bytecode, but
is very close to it.
Therefore, when the
application is executed,
the IL to machine code
conversion is quick!
MSIL converted to

CPU-specific code by
CLR
CPU-independent set of
instructions
.NET
source
code
Language
Compiler
MSIL
+
Metadat
a
Machine
code
Code
executed
CLR
CLR
Manages memory
Makes it easy to design
components &
applications whose
objects interact across
languages
Cross-language
integration
(especially cross-
language
inheritance)

Compile once, and run on
any CPU & OS that supports
the runtime!
Visual C#.Net và các khái ni m c b nệ ơ ả

Đ c phát tri n b i Microsoft do nhóm ượ ể ở Anders Hejlsberg và
Scott Wiltamuth sáng tác.

Ngôn ng l p trình tr c quan, h ng s ki n, h ng đ i ữ ậ ự ướ ự ệ ướ ố
t ng.ượ

D a theo ý t ng các ngôn ng khác : C,C++, Java và ự ưở ữ
Visual Basic.

H tr đ y đ b i ổ ợ ầ ủ ở .Net Platform.

Compiler hi u qu nh t trong ệ ả ấ .Net family.

Kh năng thay th cho C++.ả ế

H n ch s d ng con tr .ạ ế ử ụ ỏ
Ch ng trình C#ươ
using System;
class SampleCSharp
{
static void Main(string[] args)
{
Console.WriteLine("Hello world");
}
}

Các ki u d li u trong C#ể ữ ệ

Các ki u d li u đ n gi n : ể ữ ệ ơ ả int, float, string , char, bool

Các ki u d li u tham chi u : đ i t ng, l pể ữ ệ ế ố ượ ớ .

Các b t khi s d ng v i bi n : ổ ừ ử ụ ớ ế private, public, protected

Các ki u d li u khác : ể ữ ệ Array, Struct, Enum

Giá tr m c đ nh cho các ki u d li u :ị ặ ị ể ữ ệ
Nh p và xu t trong C#ậ ấ

S d ng các ph ng th c c a l p ử ụ ươ ứ ủ ớ Console trong namspace
System.

Console.WriteLine()

Console.Write()

Console.ReadLine()

Console.Read ()
Ví d :ụ
using System;
class SampleCSharp
{
static void Main(string[] args)
{
//Nhập vào 1 chuổi

string s = Console.ReadLine();

//Nhập vào số nguyên
int n = int.Parse(Console.ReadLine());
//In ra mà hình
Console.WriteLine("s = {0} va n = {1}",s,i);
}
}
C u trúc ấ If

Cú pháp :
if (bi u th c )ể ứ
{
//Các câu l nh …ệ
}
else
{
//Cá câu l nh … ệ
}

×