C# co ban 1-HHK
-
Upload
firestorm9999 -
Category
Documents
-
view
127 -
download
0
Transcript of C# co ban 1-HHK
![Page 1: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/1.jpg)
Lập trình trên Windows với Microsoft® .NET
Gi ng viên : H Hoàn Ki mả ồ ế
![Page 2: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/2.jpg)
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 ộ ọ
![Page 3: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/3.jpg)
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.ớ ệ
![Page 4: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/4.jpg)
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
![Page 5: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/5.jpg)
XML Web Services
Devices
Servers
User Experiences
Developer Tools
.NET Platform
![Page 6: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/6.jpg)
.NET Framework
Common Language Common Language RuntimeRuntime
Class LibraryClass Library
Windows
Web Services
ADO.NET
Data Types
Visual Basic Applications
Visual C# Applications
Visual C++ Applications
Programming Services
.NET Platform
Code
Source code compiles as MSIL
JIT compiler producesmachine language
![Page 7: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/7.jpg)
One-stop Application Development
Visual Studio .NET
DesignDesign DevelopDevelop DebugDebug DeployDeploy
Data AccessXML WebServices Tools
WindowsForms Tools
Web Forms Tools
Error Handling
MultipleLanguages
Các đ c đi m c a Visual Studio .NETặ ể ủ
![Page 8: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/8.jpg)
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…)ướ ế ứ ụ
![Page 9: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/9.jpg)
Microsoft Intermediate Language (MSIL)Microsoft Intermediate Language (MSIL)
Common Language SpecificationCommon Language Specification
VBVB C++C++ C#C# JScriptJScript J#J#
Common Language Runtime (CLR)Common Language Runtime (CLR)
Just In-Time Compiler (JIT)Just In-Time Compiler (JIT)
Operating SystemOperating System
MSIL, JIT và CLR
![Page 10: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/10.jpg)
Th c thi m t ch ng trình .Netự ộ ươ
C#Code
C#Compiler
Visual BasicCode
Visual BasicCompiler
COBOLCode
COBOLCompiler
ILJIT
Compiler
NativeCode
![Page 11: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/11.jpg)
.NET source
code
Lang
uage
Com
pile
r MSIL+
MetadataMachine
codeCode
executedCLR
1st Compilation
2nd Compilation
Th c thi các ch ng trình .NETự ươ
![Page 12: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/12.jpg)
Microsoft Intermediate Language
.NET source
code
Lang
uage
Com
pile
r MSIL+
MetadataMachine
codeCode
executedCLRMSIL
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
![Page 13: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/13.jpg)
.NET source
code
Lang
uage
Com
pile
r MSIL+
Metadata
Machinecode
Code executedC
LRCLRManages 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!
![Page 14: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/14.jpg)
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 .ạ ế ử ụ ỏ
![Page 15: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/15.jpg)
Ch ng trình C#ươ
using System;class SampleCSharp
{
static void Main(string[] args)
{
Console.WriteLine("Hello world");
}
}
![Page 16: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/16.jpg)
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 :ị ặ ị ể ữ ệ
![Page 17: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/17.jpg)
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 ()
![Page 18: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/18.jpg)
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);
}}
![Page 19: C# co ban 1-HHK](https://reader035.fdocuments.net/reader035/viewer/2022081413/546f3d52b4af9f68018b470c/html5/thumbnails/19.jpg)
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 … ệ}