Programming C#, 2nd Edition.pdf

(7324 KB) Pobierz
Programming C#, 2nd Edition
5073704.001.png
Programming C#, 2 nd Edition
Jesse Liberty
Publisher: O'Reilly
Second Edition February 2002
ISBN: 0-596-00309-9, 648 pages
The first part of Programming C# , 2nd Edition introduces C# fundamentals, then goes on to
explain the development of desktop and Internet applications, including Windows Forms,
ADO.NET, ASP.NET (including Web Forms), and Web Services. Next, this book gets to the
heart of the .NET Framework, focusing on attributes and reflection, remoting, threads and
synchronization, streams, and finally, it illustrates how to interoperate with COM objects.
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
6. Operator Overloading .........................................
6.1 Using the operator Keyword ....................................
6.2 Supporting Other .NET Languages ................................
6.3 Creating Useful Operators .....................................
6.4 Logical Pairs ..............................................
6.5 The Equals Operator .........................................
6.6 Conversion Operators ........................................
114
114
115
115
115
115
116
7. Structs ....................................................
7.1 Defining Structs ............................................
7.2 Creating Structs ............................................
123
123
125
8. Interfaces ..................................................
8.1 Implementing an Interface .....................................
8.2 Accessing Interface Methods ...................................
8.3 Overriding Interface Implementations ..............................
8.4 Explicit Interface Implementation ................................
130
130
138
143
147
9. Arrays, Indexers, and Collections .................................
9.1 Arrays ..................................................
9.2 The foreach Statement ........................................
9.3 Indexers .................................................
9.4 Collection Interfaces .........................................
9.5 Array Lists ...............................................
9.6 Queues ..................................................
9.7 Stacks ..................................................
9.8 Dictionaries ...............................................
156
156
160
173
181
186
196
198
201
10. Strings and Regular Expressions .................................
10.1 Strings .................................................
10.2 Regular Expressions ........................................
208
208
222
11. Handling Exceptions .........................................
11.1 Throwing and Catching Exceptions ..............................
11.2 Exception Objects ..........................................
11.3 Custom Exceptions .........................................
11.4 Rethrowing Exceptions ......................................
233
233
242
245
247
12. Delegates and Events .........................................
12.1 Delegates ...............................................
12.2 Events .................................................
251
251
270
II: Programming with C# ........................................
279
13. Building Windows Applications .................................
13.1 Creating a Simple Windows Form ...............................
13.2 Creating a Windows Form Application ............................
13.3 XML Documentation Comments ................................
13.4 Deploying an Application .....................................
280
281
292
314
316
14. Accessing Data with ADO.NET ..................................
14.1 Relational Databases and SQL ..................................
14.2 The ADO.NET Object Model ..................................
14.3 Getting Started with ADO.NET .................................
14.4 Using OLE DB Managed Providers ..............................
14.5 Working with Data-Bound Controls ..............................
14.6 Changing Database Records ...................................
14.7 ADO.NET and XML ........................................
326
326
329
331
335
337
348
363
15. Programming Web Applicationswith Web Forms .....................
15.1 Understanding Web Forms ....................................
15.2 Creating a Web Form ........................................
15.3 Adding Controls ...........................................
15.4 Data Binding .............................................
15.5 Responding to Postback Events .................................
15.6 ASP.NET and C# ..........................................
364
364
367
370
372
380
381
16. Programming Web Services ....................................
16.1 SOAP, WSDL, and Discovery ..................................
16.2 Building a Web Service ......................................
16.3 Creating the Proxy .........................................
382
382
383
389
III: Introduction to Web Services ...................................
394
17. Assemblies and Versioning .....................................
17.1 PE Files ................................................
17.2 Metadata ................................................
17.3 Security Boundary .........................................
17.4 Versioning ...............................................
17.5 Manifests ...............................................
17.6 Multi-Module Assemblies ....................................
17.7 Private Assemblies .........................................
17.8 Shared Assemblies .........................................
395
395
395
395
396
396
398
406
406
18. Attributes and Reflection ......................................
18.1 Attributes ...............................................
18.2 Intrinsic Attributes .........................................
18.3 Custom Attributes ..........................................
18.4 Reflection ...............................................
18.5 Reflection Emit ...........................................
412
412
412
414
418
428
19. Marshaling and Remoting .....................................
19.1 Application Domains ........................................
19.2 Context .................................................
19.3 Remoting ...............................................
451
452
461
463
20. Threads and Synchronization ...................................
20.1 Threads .................................................
20.2 Synchronization ...........................................
20.3 Race Conditions and Deadlocks .................................
473
473
481
491
Zgłoś jeśli naruszono regulamin