Tài liệu C# 2.0: Practical Guide for Programmers!

Thảo luận trong 'Lập Trình' bắt đầu bởi Thúy Viết Bài, 5/12/13.

  1. Thúy Viết Bài

    Thành viên vàng

    Bài viết:
    198,891
    Được thích:
    173
    Điểm thành tích:
    0
    Xu:
    0Xu
    Preface xv
    1 Introducing C# and .NET 1

    1.1 What Is C#? 1
    1.2 What Is the .NET Framework? 2
    1.2.1 The .NET Virtual Machine: Common Language
    Runtime 4
    1.2.2 The .NET Virtual Code: Intermediate Language 4
    1.2.3 The .NET Assemblies: Applications and/or
    Components 4
    1.3 Project Exercise 5
    1.4 Syntax Notation 6
    2 Classes, Objects, and Namespaces 9
    2.1 Classes and Objects 10
    2.1.1 Declaring Classes 10
    2.1.2 Creating Objects 11
    2.2 Access Modifiers 12
    2.2.1 Controlling Access to Classes 12
    2.2.2 Controlling Access to Class Members 12
    2.3 Namespaces 14
    2.3.1 Declaring Namespaces 14
    2.3.2 Importing Namespaces 16
    2.3.3 Controlling the Global Namespace 17
    2.3.4 Resolving Namespace Conflicts 18
    ix
    x Contents ■
    2.4 Compilation Units 19
    2.4.1 Presenting a Complete C# Program 19
    2.4.2 Declaring Partial Classes 21
    2.5 Compilation and Execution 22
    2.5.1 Using Assemblies for Separate Compilation 23
    2.5.2 Revisiting Access Modifiers 24
    2.5.3 Adding XML Documentation 26
    3 Class Members and Class Reuse 29
    3.1 Fields and Methods 29
    3.1.1 Invoking Methods 30
    3.1.2 Accessing Fields 32
    3.1.3 Declaring Constructors 32
    3.1.4 Declaring Destructors 36
    3.2 Parameter Passing 37
    3.2.1 Passing Arguments by Value 37
    3.2.2 Passing Arguments by Reference 38
    3.2.3 Passing a Variable Number of Arguments 41
    3.2.4 Using the this Reference 42
    3.2.5 Overloading Methods 45
    3.3 Class Reuse 45
    3.3.1 Using Aggregation 46
    3.3.2 Using Inheritance 46
    3.3.3 Comparing Aggregation and Inheritance 50
    3.3.4 Using Protected Methods 51
    4 Unified Type System 55
    4.1 Reference Types 56
    4.2 Value Types 56
    4.2.1 Simple Value Types 57
    4.2.2 Nullable Types 58
    4.2.3 Structure Types 60
    4.2.4 Enumeration Types 61
    4.3 Literals 63
    4.4 Conversions 64
    4.5 Boxing and Unboxing 66
    4.6 The Object Root Class 67
    4.6.1 Calling Virtual Methods 67
    4.6.2 Invoking the Object Constructor 69
    4.6.3 Using Object Instance Methods 69
    4.6.4 Using Object Static Methods 75
    4.7 Arrays 76
    4.7.1 Creating and Initializing Arrays 77
    ■ Contents xi
    4.7.2 Accessing Arrays 78
    4.7.3 Using Rectangular and Jagged Arrays 78
    4.8 Strings 79
    4.8.1 Invoking String Methods 80
    4.8.2 Concat, IndexOf, and Substring Methods 80
    4.8.3 The StringBuilder Class 81
    5 Operators, Assignments, and Expressions 83
    5.1 Operator Precedence and Associativity 83
    5.2 Assignment Operators 84
    5.2.1 Simple Assignment 84
    5.2.2 Multiple Assignments 86
    5.3 Conditional Operator 86
    5.4 Null Coalescing Operator 87
    5.5 Conditional Logical Operators 88
    5.6 Logical Operators 89
    5.6.1 Logical Operators as Conditional Logical Operators 90
    5.6.2 Compound Logical Assignment Operators 91
    5.7 Equality Operators 92
    5.7.1 Simple Value Type Equality 92
    5.7.2 Object Reference and Value Equality 93
    5.8 Relational Operators 94
    5.8.1 Type Testing 95
    5.9 Shift Operators 96
    5.9.1 Compound Shift Assignment Operators 97
    5.10 Arithmetic Operators 97
    5.10.1 Multiplicative Operators 97
    5.10.2 Additive Operators 98
    5.10.3 checked/unchecked Operators 99
    5.10.4 Compound Arithmetic Assignment Operators 100
    5.11 Unary Operators 101
    5.11.1 Prefix and Postfix Operators 102
    5.11.2 Explicit Casts 103
    5.12 Other Primary Operators 103
    5.13 Overloadable Operators 104
    6 Statements and Exceptions 107
    6.1 Block Statement 107
    6.2 Declaration Statements 108
    6.3 Embedded Statements 109
    6.3.1 Expression and Empty Statements 109
    6.3.2 Selection Statements 110
    xii Contents ■
    6.3.3 Iteration Statements 112
    6.3.4 Jump Statements 114
    6.3.5 checked/unchecked Statements 116
    6.3.6 lock and using Statements 116
    6.4 Exceptions and Exception Handling 117
    6.4.1 What Is an Exception? 117
    6.4.2 Raising and Handling Exceptions 118
    6.4.3 Using the throw Statement 119
    6.4.4 Using the try-catch Statement 121
    6.4.5 An Extended Example 124
    7 Advanced Types, Polymorphism, and Accessors 129
    7.1 Delegates and Events 130
    7.1.1 Using Delegates for Callbacks 130
    7.1.2 Using Delegates for Events 133
    7.1.3 Using Delegates for Anonymous Methods 135
    7.1.4 Using Delegate Inferences 136
    7.2 Abstract Classes 136
    7.2.1 Declaring Abstract Classes 136
    7.2.2 Implementing Abstract Classes 137
    7.2.3 Using Abstract Classes 138
    7.3 Interfaces 138
    7.3.1 Declaring Interfaces 139
    7.3.2 Implementing Interfaces 140
    7.3.3 Using Interface Methods 141
    7.4 Polymorphism and Virtual Methods 143
    7.4.1 Using the Modifiers override and virtual 143
    7.4.2 Adding and Removing Polymorphism 145
    7.4.3 Using Dynamic Binding 146
    7.5 Properties 150
    7.5.1 Declaring get and set Accessors 150
    7.5.2 Declaring Virtual and Abstract Properties 151
    7.5.3 Declaring Static Properties 153
    7.5.4 Declaring Properties with Accessor Modifiers 154
    7.6 Indexers 155
    7.7 Nested Types 157
    7.8 Other Modifiers 159
    8 Collections and Generics 163
    8.1 Collections 163
    8.1.1 Cloning Collections 165
    8.1.2 Using List-Type Collections 165
    ■ Contents xiii
    8.1.3 Using Dictionary-Type Collections 173
    8.1.4 Using Iterator Blocks and yield Statements 178
    8.2 Generics 180
    8.2.1 Defining Generics 181
    8.2.2 Declaring Generic Objects 183
    9 Resource Disposal, Input/Output, and Threads 185
    9.1 Resource Disposal 185
    9.2 Input/Output 188
    9.2.1 Using Binary Streams 188
    9.2.2 Using Byte Streams 190
    9.2.3 Using Character Streams 191
    9.2.4 Reading XML Documents from Streams 192
    9.3 Threads 193
    9.3.1 Examining the Thread Class and Thread States 193
    9.3.2 Creating and Starting Threads 194
    9.3.3 Rescheduling and Pausing Threads 195
    9.3.4 Suspending, Resuming, and Stopping Threads 196
    9.3.5 Joining and Determining Alive Threads 198
    9.3.6 Synchronizing Threads 200
    10 Reflection and Attributes 211
    10.1 Reflection 211
    10.1.1 Examining the Reflection Hierarchy 212
    10.1.2 Accessing Assemblies 212
    10.2 Attributes 215
    10.2.1 Using Attributes for Exception Serialization 216
    10.2.2 Using Attributes for Conditional Compilation 217
    10.2.3 Using Attributes for Obsolete Code 218
    10.2.4 Defining User-Defined Attributes 218
    10.2.5 Using User-Defined Attributes 220
    10.2.6 Extracting Attributes Using Reflection 221
    10.3 Where to Go from Here 223
    A C# 2.0 Grammar 227
    A.1 Lexical Grammar 227
    A.1.1 Line Terminators 228
    A.1.2 White Space 228
    A.1.3 Comments 228
    A.1.4 Tokens 228
    A.1.5 Unicode Character Escape Sequences 228
    A.1.6 Identifiers 228
    xiv Contents ■
    A.1.7 Keywords 229
    A.1.8 Literals 229
    A.1.9 Operators and Punctuators 230
    A.1.10 Preprocessing Directives 230
    A.2 Syntactic Grammar 231
    A.2.1 Namespace, Type, and Simple Names 231
    A.2.2 Types 231
    A.2.3 Variables 232
    A.2.4 Expressions 232
    A.2.5 Statements 233
    A.2.6 Namespaces 235
    A.2.7 Classes 235
    A.2.8 Structs 237
    A.2.9 Arrays 237
    A.2.10 Interfaces 237
    A.2.11 Enums 238
    A.2.12 Delegates 238
    A.2.13 Attributes 238
    A.3 Generics 238
    B Predefined XML Tags for Documentation Comments 241
    References 243
    Index 245
     

    Các file đính kèm:

Đang tải...