Table of Contents
Preface .....................................................
About This Book ..............................................
How the Book Is Organized .......................................
Who This Book Is For ..........................................
C# Versus Visual Basic .NET .....................................
C# Versus Java ...............................................
C# Versus C++ ...............................................
Conventions Used in This Book ....................................
Support ....................................................
We'd Like to Hear from You ......................................
Acknowledgments .............................................
1
1
1
4
4
4
5
5
5
6
7
I: The C# Language ............................................
8
1. C# and the .NET Framework ....................................
1.1 The .NET Platform ..........................................
1.2 The .NET Framework ........................................
1.3 Compilation and the MSIL .....................................
1.4 The C# Language ...........................................
9
9
10
11
12
2. Getting Started: "Hello World" ..................................
2.1 Classes, Objects, and Types ....................................
2.2 Developing "Hello World" .....................................
2.3 Using the Visual Studio .NET Debugger ............................
14
14
20
23
3. C# Language Fundamentals .....................................
3.1 Types ...................................................
3.2 Variables and Constants .......................................
3.3 Expressions ...............................................
3.4 Whitespace ...............................................
3.5 Statements ................................................
3.6 Operators ................................................
3.7 Namespaces ...............................................
3.8 Preprocessor Directives .......................................
26
26
30
36
36
37
51
59
60
4. Classes and Objects ...........................................
4.1 Defining Classes ...........................................
4.2 Creating Objects ............................................
4.3 Using Static Members ........................................
4.4 Destroying Objects ..........................................
4.5 Passing Parameters ..........................................
4.6 Overloading Methods and Constructors ............................
4.7 Encapsulating Data with Properties ...............................
4.8 Readonly Fields ............................................
64
64
69
74
78
81
86
88
91
5. Inheritance and Polymorphism ...................................
5.1 Specialization and Generalization ................................
5.2 Inheritance ...............................................
5.3 Polymorphism .............................................
5.4 Abstract Classes ............................................
5.5 The Root of all Classes: Object ..................................
5.6 Boxing and Unboxing Types ....................................
5.7 Nesting Classes ............................................
93
93
95
99
104
108
109
111