Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 750 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
750
Dung lượng
20,84 MB
Nội dung
[...]... of the feature sets for the releases of C# 14 CHAPTER 2 Overview of C# Programming A Simple C# Program Identifiers Keywords Main: The Starting Point of a Program Whitespace Statements Text Output from a Program Comments: Annotating the Code 15 CHAPTER 2 OVERVIEW OF C# PROGRAMMING A Simple C# Program This chapter lays the groundwork for studying C# Since I’ll use code samples extensively... recommended C# naming conventions in Chapter 7 18 CHAPTER 2 OVERVIEW OF C# PROGRAMMING Keywords Keywords are the character string tokens used to define the C# language Table 2-2 gives a complete list of the C# keywords Some important things to know about keywords are the following: • Keywords cannot be used as variable names or any other form of identifier, unless prefaced with the @ character • All C# keywords... The topics include data types, class construction, and parameter passing 12 CHAPTER 1 C# AND THE NET FRAMEWORK Review of the Acronyms This chapter has covered a lot of NET acronyms, so Figure 1-8 will help you keep them straight Figure 1-8 The NET acronyms 13 CHAPTER 1 C# AND THE NET FRAMEWORK The Evolution of C# The current version of the language is version 5.0 Each new release of the language... code Table 2-3 contains the list of contextual keywords Table 2-3 The C# Contextual Keywords add ascending async await by descending dynamic equals from get global group in into join let on orderby partial remove select set value var where yield 19 CHAPTER 2 OVERVIEW OF C# PROGRAMMING Main: The Starting Point of a Program Every C# program must have one class with a method called Main In the SimpleProgram... studying C# Since I’ll use code samples extensively throughout the text, I first need to show you what a C# program looks like and what its various parts mean I’ll start by demonstrating a simple program and explaining its components one by one This will introduce a range of topics, from the structure of a C# program to the method of producing program output to the screen With these source code preliminaries... time 8 CHAPTER 1 C# AND THE NET FRAMEWORK Overview of Compilation and Execution The same compilation and execution process is followed regardless of the language of the original source files Figure 1-5 illustrates the entire compilation and runtime processes for three programs written in different languages Figure 1-5 Overview of the compile-time and runtime processes 9 CHAPTER 1 C# AND THE NET FRAMEWORK... Both the CLI and C# have been approved as open international standard specifications by Ecma International (The name “Ecma” used to be an acronym for the European Computer Manufacturers Association, but it’s now just a word in itself.) Ecma members include Microsoft, IBM, Hewlett-Packard, Adobe, and many other corporations associated with computers and consumer electronics 11 CHAPTER 1 C# AND THE NET... differences in appearance // Nicely formatted Main() { Console.WriteLine("Hi, there!"); } // Just concatenated Main(){Console.WriteLine("Hi, there!");} 20 CHAPTER 2 OVERVIEW OF C# PROGRAMMING Statements The statements in C# are very similar to those of C and C++ This section introduces the general form of statements; the specific statement forms are covered in Chapter 9 A statement is a source code... are {0} and {1}.", 3, 6); ↑ ↑ Format string Substitution values This code produces the following output on the screen: Two sample integers are 3 and 6 23 CHAPTER 2 OVERVIEW OF C# PROGRAMMING Multiple Markers and Values In C#, you can use any number of markers and any number of values • The values can be used in any order • The values can be substituted any number of times in the format string For... line The result is the declaration of a single variable, var2 Beginning of comment ↓ int /*var 1,*/ var2; ↑ End of comment Note Single-line and delimited comments behave in C# just as they do in C and C++ 30 CHAPTER 2 OVERVIEW OF C# PROGRAMMING More About Comments There are a couple of other important things you need to know about comments: • You cannot nest delimited comments Only one comment can . Review of the Acronyms
The Evolution of C#
CHAPTER 1 C# AND THE .NET FRAMEWORK
2
Before .NET
The C# programming language was designed for developing. focuses of the feature sets for the releases of C#
C H A P T E R 2
15
Overview of C# Programming
A Simple C# Program
Identifiers
Keywords