Slide bài giảng môn Lập trình window.net Phần 1

50 1.6K 3
Slide bài giảng môn Lập trình window.net Phần 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

TỔNG QUAN NET NGÔN NGỮ C# Nội dung Giới thiệu NET Framework 1 CLR, CTS, CLS, MSIL… Garbage collection Namespace Tổng quan ngôn ngữ C# 2 - Đặc điểm ngôn ngữ Quá trình biên dịch CT C# Các loại CT C# Cấu trúc chương trình C# Chương trình C# đơn giản .NET Framework    Chương trình tảng cho cho công nghệ NET Cung cấp tập hợp class library thường dùng Quản lý thực thi chương trình NET XML Web Web Service Forms ASP.NET Windows Forms C# VB.NET J# C++ … Custom Classes Data and XML Classes Base Framework Classes Common Language Runtime - .NET Framework - Architechture  Common Language Infrastructure (CLI)  provide a languageneutral platform for application development and execution - .NET Framework NET 3.5 (Nov-2007) VS.NET 2008 Default: Windows NET 2.0 (Nov-2005) VS.NET 2005 NET 3.0 (Nov-2006) Default: Windows Vista, Server 2008 NET 1.1 (Apr-2003) VS NET 2003 Default: Server 2003 NET 1.0 (Feb-2002) - Đặc điểm ứng dụng NET     Chạy (.NET framework) Mã nguồn biên dịch qua MSIL MSIL thông dịch qua mã máy lúc thực thi nhờ vào CLR Độc lập tảng  Về  lý thuyết chạy nền! Install NET Framework redistribute packadge (dotnetfx.exe) để chạy ứng dụng NET máy client - Đặc điểm ứng dụng NET CT C#.NET C# Compiler CT VB.NET VB NET Compiler Programmer MS IL CLR CT J#.NET CT C++.NET - J# NET Compiler C++ Compiler 101101 101101 101101 .NET Framework - CLR     Theo quan điểm người lập trình, NET hiểu môi trường thực thi thư viện lớp sở cải tiến Môi trường thực thi là: Common Language Runtime - CLR Vai trị CLR: locate, load, manage NET types CLR quản lý phần mức thấp như: memory management, security check - .NET Framework - CTS  Common Type System (CTS):  Mục đích hỗ trợ thực thi chéo ngôn ngữ  Định nghĩa kiểu liệu tiền định có sẵn IL:  Tất ngôn ngữ NET sinh mã cuối sở kiểu liệu VB.NET … Integer … - IL … Int32 … C# … int … NET Framework - CLS 10 C++ C# CLS CLR/ CTS/IL - Visual Basic CLS is the smallest common denominator of various OOlanguages FCL only uses CLS features Ứng dụng Console 36 - UD WinForm Web Form 37 - Tạo UD Console 38 - UD C# 39 // Chương trình C# using System; using System.Collections.Generic; using System.Text; namespace HelloWorld { class Program { static void Main(string[] args) { Console.Write("Hello World!"); Console.ReadLine(); } } } - Cấu trúc chương trình C# 40 Phần thích (option)  // Chương trình C# Phần khai báo dùng namespace (option)  using System; using System.Collections.Generic; using System.Text; Phần định nghĩa namespace lớp  namespace HelloWorld { class Program { static void Main(string[] args){ Console.Write("Hello World!"); Console.ReadLine(); } } } - { Câu lệnh 41 Các câu lệnh viết thân phương thức (ở phương thức Main) Thực cơng việc Kết thúc dấu chấm phẩy (;)    Phương thức Main Các câu lệnh - namespace HelloWorld { class Program { static void Main(string[] args) { Console.Write("Hello World!"); Console.ReadLine(); } } } Khoảng trắng 42 Bao gồm   Ký tự trắng, ký tự xuống dòng, ký tự tab  Dòng trống Sử dụng hợp lý  chương trình dễ đọc  namespace HelloWorld {class Program { static void Main(string[] args) { Console.Write("Hello World!"); Console.ReadLine();} } } - namespace HelloWorld { class Program { static void Main(string[] args) { Console.Write("Hello World!"); Console.ReadLine(); } } } Chú thích 43      Chú thích (comment) dùng để giải thích chương trình câu lệnh Giúp cho chương trình dễ hiểu Được bỏ qua biên dịch Không ảnh hưởng tới kết thực thi chương trình Có thể phát sinh documentation chương trình qua thích XML - Hai cách tạo thích 44   Gõ phần thích sau cặp ký tự // Gõ phần thích cặp ký tự /* */ /* Chương trình C# In câu chào "Hello World" */ using System; namespace HelloWorld { class Program { static void Main(string[] args) { Console.Write("Hello World!"); // Xuất câu chào Console.ReadLine(); // Chờ nhấn Enter } } } - XML Comment 45 Cho phép phát sinh sưu liệu dạng XML Thích hợp cho việc viết sưu liệu dự án lớn Chú thích XML bắt đầu với triple slash (“///”) tag XML Chú thích XML dùng cho      User defined types  Class, delegate, enum and struct  Member of user defined types - XML Comment 46 C# C ode wi thout X M L Co mm en using System; namespace XMLCommentDemo { public class Temperature { public static int CelsiusToFahrenheit(int degreesCelsius) { return ((int)((9/5)*degreesCelsius) + 32); } public static int FahrenheitToCelsius(int degressFahrenheit) { return ((int)((5/9)*(degressFahrenheit - 32))); } } } - XML Comment 47 Comment for class  /// /// Class temperature provides functions which convert /// among various temperature scales /// public class Temperature Comment for method  /// /// Converts degrees Celsius to degrees Fahrenheit /// /// Degrees Celsius /// Returns degrees Fahrenheit public static int CelsiusToFahrenheit(int degreesCelsius) - XML Comment 48 C# Co d e wi th XM L Com m en t using System; namespace XMLCommentDemo{ /// /// Class temperature provides functions which convert among various /// temperature scales /// public class Temperature { /// /// Converts degrees Celsius to degrees Fahrenheit /// /// Degrees Celsius /// Returns degrees Fahrenheit public static int CelsiusToFahrenheit(int degreesCelsius) { return ((int)((9/5)*degreesCelsius) + 32); } /// /// Converts degrees Fahrenheit to degrees Celsius /// /// Degrees Fahrenheit /// Returns degrees Celsius public static int FahrenheitToCelsius(int degressFahrenheit) { return ((int)((5/9)*(degressFahrenheit - 32))); } } } - Tóm tắt 49  C# ngơn ngữ lập trình NET Là ngơn ngữ đại  Hướng đối tượng, hướng thành phần  An toàn kiểu, mạnh mẽ, bền bỉ   Có ba loại chương trình C#   Console, Windows Form, Web Form Tạo chương trình C# đơn giản Tạo ứng dụng Console  Viết câu lệnh thân phương thức Main  - Demo 50 - ... IL CLR CT J#.NET CT C++.NET - J# NET Compiler C++ Compiler 10 110 1 10 110 1 10 110 1 .NET Framework - CLR     Theo quan điểm người lập trình, NET hiểu mơi trường thực thi thư viện lớp sở cải tiến... Cấu trúc chương trình C# 40 Phần thích (option)  // Chương trình C# Phần khai báo dùng namespace (option)  using System; using System.Collections.Generic; using System.Text; Phần định nghĩa... ngơn ngữ lập trình NET Là ngơn ngữ đại  Hướng đối tượng, hướng thành phần  An toàn kiểu, mạnh mẽ, bền bỉ   Có ba loại chương trình C#   Console, Windows Form, Web Form Tạo chương trình C#

Ngày đăng: 19/03/2014, 20:18

Từ khóa liên quan

Mục lục

  • TỔNG QUAN .NET NGÔN NGỮ C#

  • Nội dung

  • .NET Framework

  • .NET Framework - Architechture

  • Slide 5

  • Đặc điểm của ứng dụng .NET

  • Slide 7

  • .NET Framework - CLR

  • .NET Framework - CTS

  • . NET Framework - CLS

  • Slide 11

  • MS Intermediate Language

  • Common Language Runtime - compilation

  • Assembly

  • Managed Code

  • Garbage collection

  • Slide 17

  • Namespace

  • Slide 19

  • Slide 20

Tài liệu cùng người dùng

Tài liệu liên quan