1 / 52

Week 1: Introduce

Week 1: Introduce. ➤ What is the .NET Framework ? CLR , MSIL,IL ,FLC Garbage collection Namespace ➤ What C# is and how it relates to the .NET Framework. WHAT IS THE .NET FRAMEWORK?. Microsoft’s modern software development platform Programs executed by Common Language Runtime (CLR )

jess
Download Presentation

Week 1: Introduce

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week 1: Introduce ➤What is the .NET Framework ? CLR, MSIL,IL,FLC Garbage collection Namespace ➤ What C# is and how it relates to the .NET Framework

  2. WHAT IS THE .NET FRAMEWORK? • Microsoft’s modern software development platform • Programs executed by Common Language Runtime (CLR) • FLC(Framework class library) Includes a large library of components (classes) which can be used in programs • Supports several programming languages, including C#, Visual Basic, C++, J# Windows Programming 1 Chapter 1: Introducing C# Slide 2

  3. .NET Framework Windows Programming 1 Chapter 1: Introducing C# Slide 3

  4. .NET Framework .NET 4.0 (2010) VS.NET 2010 Default: Windows 7 .NET 3.5 (Nov-2007) VS.NET 2008 Default: Windows 7 .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)

  5. Writing Applications Using the .NET Framework • CLR:Common Language Runtime • MSIL or IL: Microsoft Intermediate Language • JIT: just-In-Time compiler • Assemblies • Managed Code • Garbage Collection Windows Programming 1 Chapter 1: Introducing C# Slide 5

  6. .NET Framework -CLR • Common Language Runtime Architecture Windows Programming 1 Chapter 1: Introducing C# Slide 6

  7. MS IL CLR Writing Applications Using the .NET Framework .NET Framework CT C#.NET C# Compiler Programmer CT VB.NET VB .NET Compiler 1011010 1011010 1011010 CT J#.NET J# .NET Compiler CT C++.NET C++ Compiler

  8. Writing Applications Using the .NET Framework Windows Programming 1 Chapter 1: Introducing C# Slide 8

  9. Assembly • Managed Modules • Chứa IL code để thực thi • Chứa resource, metadata… • Portable Executable (PE) • Process assembly (EXE) • Library assembly (DLL) .NET Assembly EXE DLL

  10. Managed Code • Software that is written using the .NET Framework is called Managed Legacy Software (unmanaged code) Managed Executable Common Language Runtime Windows (OS khác)

  11. Garbage collection class myClass{ void Method(){ variable v1; variable v2; do{ …. } } Managed Heap B A E C D A và D sẽ bị xoá do ko còn tham chiếu hay truy cập tới

  12. Namespaces • Namespaces are also used as a means of categorizing items in the .NET Framework • Qualified names use period characters (.) between namespace levels • Within a namespace, you can define nested namespaces, also using the namespace keyword. Windows Programming 1 Chapter3: Variables and Expressions Slide 12

  13. Namespaces Windows Programming 1 Chapter3: Variables and Expressions Slide 13

  14. Namespace

  15. Framework (Base) Class Library FCL/BCL • Đặc tính lõi: IL, kiểu dữ liệu trong CTS • Hỗ trợ Win GUI và control • WebForm (ASP.NET) • Data Access (ADO.NET) • Directory Access • File System, registry access • Networking and web browsing • .NET attributes and reflection • WinOS access • COM interoperability

  16. Run .NET App from Client • Required MS .NET Framework compatible • MS .NET Framework 2.0, 3.5 • Install .NET 3.5 Full Redistributable package • (dotnetfx35.exe, 197MB) • Windows Vista comes with .NET Framework 3.0 • Windows 7 comes with .NET Framework 4.0 .NET App .NET App .NET App

  17. C# Language

  18. WHAT IS C#? • Applications You Can Write with C# • Windows applications • Web applications • Web services: Windows Programming 1 Chapter 1: Introducing C# Slide 18

  19. Visual Studio • Powerful, professional Integrated Development Environment (IDE) • Integrates compilers, debugger and many other useful tools for development • Can work with many different types of project, including: • Console (text-based) applications • Windows (GUI) applications • Web applications (ASP.NET) • Class libraries Windows Programming 1 Chapter 1: Introducing C# Slide 19

  20. Visual Studio Solution explorer Visual designer Toolbox windows Properties windows Windows Programming 1 Chapter 1: Introducing C# Slide 20

  21. Visual Studio projects • A project contains source code files, settings and resources for an application • May contain references to class libraries • May contain data used by application • Building a project: • Compiles source files • Copies non-source files to output folder • Creates an assembly in output folder • Building a solution builds all its projects Windows Programming 1 Chapter 1: Introducing C# Slide 21

  22. Project details Solution folder contents Project folder contents References – class libraries used by this application Solution file (.sln) and project file (.csproj) are created by VS and contain solution/project configuration information Windows Programming 1 Chapter 1: Introducing C# Slide 22

  23. Creating a Visual Studio project • Demo Windows Programming 1 Chapter 1: Introducing C# Slide 23

  24. Week 1: THE C# LANGUAGE Chapter 2: Writing a C# Program A basic working knowledge of Visual Studio 2010 and Visual C# 2010 Express Edition How to write a simple console application How to write a Windows Forms application

  25. Visual C# 2010 Ultimate Windows Programming 1 Chapter 2: Writing a C# Program Slide 25

  26. CONSOLE APPLICATIONS Windows Programming 1 Chapter 2: Writing a C# Program Slide 26

  27. WINDOWS FORMS APPLICATIONS • MO_BAI1 Windows Programming 1 Chapter 2: Writing a C# Program Slide 27

  28. The Solution Explorer Windows Programming 1 Chapter 1: Introducing C# Slide 28

  29. The Properties Window Windows Programming 1 Chapter 1: Introducing C# Slide 29

  30. Code view Windows Programming 1 Chapter 1: Introducing C# Slide 30

  31. The Error List Window Windows Programming 1 Chapter 1: Introducing C# Slide 31

  32. SUMMARY ? ? ? Windows Programming 1 Chapter 2: Writing a C# Program Slide 32

  33. Week 1: THE C# LANGUAGE Chapter 3:Variables and Expressions Basic C# syntax Variables and how to use them Expressions and how to use them

  34. BASIC C# SYNTAX • The look and feel of C# code is similar to that of C++ and Java. • C# compilers ignore additional spacing in code, whether it results from spaces, carriage returns, or tab characters (collectively known as whitespace characters). • Statements • C# is a block-structured language, meaning statements are part of a block of code. Windows Programming 1 Chapter3: Variables and Expressions Slide 34

  35. block • These blocks, which are delimited with curly brackets ({ and }), may contain any number of statements, or none at all Windows Programming 1 Chapter3: Variables and Expressions Slide 35

  36. comments • Comments can be created using //… • Multi-lines comments use /* … */ • You can use single-line comments that start with three / symbols instead of two /// A special comment • Comments are ignored by the compiler • Used only for human readers Windows Programming 1 Chapter3: Variables and Expressions Slide 36

  37. The code outlining • You can do this with the #region and #endregion keywords, which define the start and end of a region of code that can be expanded and collapsed. Windows Programming 1 Chapter3: Variables and Expressions Slide 37

  38. VARIABLES • C# syntax for declaring variables merely specifies the type and variable name: <type> <name>; int intNumberOfStudents; • Declaration includes • Name, follow Naming Convention Rules • Data Type • Required Value for Constants • Optional Initial Value for Variables Windows Programming 1 Chapter3: Variables and Expressions Slide 38

  39. Simple Types Windows Programming 1 Chapter3: Variables and Expressions Slide 39

  40. Simple Types Windows Programming 1 Chapter3: Variables and Expressions Slide 40

  41. Simple Types Windows Programming 1 Chapter3: Variables and Expressions Slide 41

  42. Using Simple Type Variables • Mo_b3 Windows Programming 1 Chapter3: Variables and Expressions Slide 42

  43. Variable Naming • The first character of a variable name must be either a letter, an underscore character ( _ ), or the at symbol (@). • Subsequent characters may be letters, underscore characters, or numbers. Windows Programming 1 Chapter3: Variables and Expressions Slide 43

  44. String Literals Windows Programming 1 Chapter3: Variables and Expressions Slide 44

  45. String Literals • This means that the following strings are equivalent: "Karli \’s string." "Karli \u0027 s string.“ • @ "A short list: item 1 item 2“ • "C:\\Temp\\MyDir\\MyFile.doc“ @ "C:\Temp\MyDir\MyFile.doc" Windows Programming 1 Chapter3: Variables and Expressions Slide 45

  46. EXPRESSIONS • Operators can be roughly classified into three categories: • ➤ Unary— Act on single operands • ➤ Binary—Act on two operands • ➤ Ternary—Act on three operands Windows Programming 1 Chapter3: Variables and Expressions Slide 46

  47. Mathematical Operators Windows Programming 1 Chapter3: Variables and Expressions Slide 47

  48. Windows Programming 1 Chapter3: Variables and Expressions Slide 48

  49. Manipulating Variables with Mathematical Operators Windows Programming 1 Chapter3: Variables and Expressions Slide 49

  50. Assignment Operators Windows Programming 1 Chapter3: Variables and Expressions Slide 50

More Related