Download presentation
Presentation is loading. Please wait.
Published byElisabeth Payne Modified over 9 years ago
1
Week 1: THE C# LANGUAGE Chapter 1: Variables and Expressions ➤ Included in Visual Studio.NET ➤ What the.NET Framework is and what it contains ➤ How.NET applications work ➤ What C# is and how it relates to the.NET Framework ➤ What tools are available for creating.NET applications with C#
2
Included in Visual Studio.NET Visual Basic (VB.Net, VB 7.0) C++ C# (đọc là C Sharp) J# (J Sharp).NET Framework Windows Programming 1 Chapter 1: Introducing C#Slide 2
3
Install Visual Studio.NET 2010 Windows Programming 1 Chapter 1: Introducing C#Slide 3 Chạy file setup.exe ta được hình minh họa (chú ý cài khá lâu có thể hơn 45phút)
4
Install Visual Studio.NET 2010 Windows Programming 1 Chapter 1: Introducing C#Slide 4 Trên windows XP phải Service pack3
5
Install Visual Studio.NET 2010 Windows Programming 1 Chapter 1: Introducing C#Slide 5 Trên windows XP phải Service pack3 Chú ý Nên chọn full
6
WHAT IS THE.NET FRAMEWORK? Understanding the.NET Framework Architecture Windows Programming 1Chapter 1: Introducing C#Slide 6
7
WHAT IS THE.NET FRAMEWORK? Common Language Runtime Architecture Windows Programming 1Chapter 1: Introducing C#Slide 7
8
WHAT IS THE.NET FRAMEWORK? Microsoft’s modern software development platform Supports several programming languages, including C#, Visual Basic, C++, J# Programs executed by Common Language Runtime (CLR) Includes a large library of components (classes) which can be used in programs Windows Programming 1Chapter 1: Introducing C#Slide 8
9
Writing Applications Using the.NET Framework CIL (Common Intermediate Language code.), JIT (just-in-time compiler) MSIL or IL (Microsoft Intermediate Language ) Assemblies Managed Code Garbage Collection Windows Programming 1Chapter 1: Introducing C#Slide 9
10
Writing Applications Using the.NET Framework Windows Programming 1Chapter 1: Introducing C#Slide 10 C# Code C# Compiler Visual Basic Code Visual Basic Compiler COBOL Code COBOL Compiler IL JIT Compiler Native Code
11
Writing Applications Using the.NET Framework Windows Programming 1Chapter 1: Introducing C#Slide 11
12
WHAT IS C#? Applications You Can Write with C# Windows applications Web applications: Web services: Windows Programming 1Chapter 1: Introducing C#Slide 12
13
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 1Chapter 1: Introducing C#Slide 13
14
Visual Studio Solution explorer Toolbox windows Visual designer Properties windows Windows Programming 1Chapter 1: Introducing C#Slide 14
15
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 1Chapter 1: Introducing C#Slide 15
16
Project details References – class libraries used by this application References – class libraries used by this application Solution folder contents Project folder contents Solution file (.sln) and project file (.csproj) are created by VS and contain solution/project configuration information Windows Programming 1Chapter 1: Introducing C#Slide 16
17
Creating a Visual Studio project Demo Windows Programming 1Chapter 1: Introducing C#Slide 17
18
SUMMARY Windows Programming 1Chapter 1: Introducing C#Slide 18
19
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
20
Visual C# 2010 Ultimate Windows Programming 1 Chapter 2: Writing a C# Program Slide 20
21
CONSOLE APPLICATIONS Windows Programming 1 Chapter 2: Writing a C# Program Slide 21
22
WINDOWS FORMS APPLICATIONS Windows Programming 1 Chapter 2: Writing a C# Program Slide 22
23
The Solution Explorer Windows Programming 1 Chapter 1: Introducing C#Slide 23
24
The Properties Window Windows Programming 1 Chapter 1: Introducing C#Slide 24
25
Code view Windows Programming 1 Chapter 1: Introducing C#Slide 25
26
The Error List Window Windows Programming 1 Chapter 1: Introducing C#Slide 26
27
SUMMARY Windows Programming 1 Chapter 2: Writing a C# Program Slide 27
28
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
29
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 29
30
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 30
31
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 31
32
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 32
33
VARIABLES C# syntax for declaring variables merely specifies the type and variable 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 33
34
Simple Types Windows Programming 1 Chapter3: Variables and Expressions Slide 34
35
Simple Types Windows Programming 1 Chapter3: Variables and Expressions Slide 35
36
Simple Types Windows Programming 1 Chapter3: Variables and Expressions Slide 36
37
Using Simple Type Variables Windows Programming 1 Chapter3: Variables and Expressions Slide 37
38
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 38
39
String Literals Windows Programming 1 Chapter3: Variables and Expressions Slide 39
40
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 40
41
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 41
42
Mathematical Operators Windows Programming 1 Chapter3: Variables and Expressions Slide 42
43
Windows Programming 1 Chapter3: Variables and Expressions Slide 43
44
Manipulating Variables with Mathematical Operators Windows Programming 1 Chapter3: Variables and Expressions Slide 44
45
Assignment Operators Windows Programming 1 Chapter3: Variables and Expressions Slide 45
46
Operator Precedence Windows Programming 1 Chapter3: Variables and Expressions Slide 46
47
Namespaces Namespaces are also used as a means of categorizing items in the.NET Framework C# code, by default, is contained in the global namespace Qualified names use period characters (.) between namespace levels System.Int32 Windows Programming 1 Chapter3: Variables and Expressions Slide 47
48
Namespaces Windows Programming 1 Chapter3: Variables and Expressions Slide 48 Code in the global namespace, however, must refer to this name using the classified name LevelOne.NameOne.
49
Namespaces Within a namespace, you can define nested namespaces, also using the namespace keyword. Windows Programming 1 Chapter3: Variables and Expressions Slide 49
50
SUMMARY Windows Programming 1 Chapter 3: Variables and Expressions Slide 50
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.