INTRODUCTION |
|
xxxiii | |
PART I: THE C# LANGUAGE |
|
|
CHAPTER 1: INTRODUCING C# |
|
|
3 | |
|
What is the .NET Framework? |
|
|
3 | |
|
What's in the .NET Framework? |
|
|
4 | |
|
Writing Applications Using the .NET Framework |
|
|
5 | |
|
|
5 | |
|
|
5 | |
|
|
6 | |
|
|
6 | |
|
|
7 | |
|
|
8 | |
|
|
8 | |
|
Applications You Can Write with C# |
|
|
9 | |
|
|
10 | |
|
|
10 | |
|
Visual Studio 2010 Express Products |
|
|
11 | |
|
|
11 | |
|
|
11 | |
|
CHAPTER 2: WRITING A C# PROGRAM |
|
|
13 | |
|
The Development Environments |
|
|
14 | |
|
|
14 | |
|
Visual C# 2010 Express Edition |
|
|
17 | |
|
|
18 | |
|
|
22 | |
|
|
23 | |
|
|
23 | |
|
Windows Forms Applications |
|
|
24 | |
|
|
28 | |
|
CHAPTER 3: VARIABLES AND EXPRESSIONS |
|
|
31 | |
|
|
32 | |
|
Basic C# Console Application Structure |
|
|
34 | |
|
|
35 | |
|
|
36 | |
|
|
40 | |
|
|
41 | |
|
|
42 | |
|
|
43 | |
|
Variable Declaration and Assignment |
|
|
44 | |
|
|
45 | |
|
|
45 | |
|
|
50 | |
|
|
51 | |
|
|
51 | |
|
|
55 | |
|
|
59 | |
|
|
59 | |
|
Boolean Assignment Operators |
|
|
62 | |
|
|
64 | |
|
Operator Precedence Updated |
|
|
68 | |
|
|
68 | |
|
|
69 | |
|
|
70 | |
|
|
70 | |
|
Checking More Conditions Using if Statements |
|
|
73 | |
|
|
74 | |
|
|
77 | |
|
|
78 | |
|
|
80 | |
|
|
83 | |
|
|
87 | |
|
|
88 | |
|
|
89 | |
|
CHAPTER 5: MORE ABOUT VARIABLES |
|
|
93 | |
|
|
94 | |
|
|
94 | |
|
|
96 | |
|
Explicit Conversions Using the Convert Commands |
|
|
99 | |
|
|
102 | |
|
|
102 | |
|
|
103 | |
|
|
107 | |
|
|
107 | |
|
|
110 | |
|
|
110 | |
|
|
113 | |
|
|
113 | |
|
|
115 | |
|
|
116 | |
|
|
121 | |
|
|
125 | |
|
Defining and Using Functions |
|
|
126 | |
|
|
128 | |
|
|
130 | |
|
|
132 | |
|
|
132 | |
|
Reference and Value Parameters |
|
|
134 | |
|
|
136 | |
|
|
137 | |
|
Variable Scope in Other Structures |
|
|
140 | |
|
Parameters and Return Values versus Global Data |
|
|
142 | |
|
|
143 | |
|
|
146 | |
|
|
147 | |
|
|
149 | |
|
|
152 | |
|
CHAPTER 7: DEBUGGING AND ERROR HANDLING |
|
|
155 | |
|
|
156 | |
|
Debugging in Nonbreak (Normal) Mode |
|
|
157 | |
|
Outputting Debugging Information |
|
|
158 | |
|
|
163 | |
|
Diagnostics Output Versus Tracepoints |
|
|
164 | |
|
|
166 | |
|
|
166 | |
|
Monitoring Variable Content |
|
|
170 | |
|
|
172 | |
|
Immediate and Command Windows |
|
|
173 | |
|
|
174 | |
|
|
175 | |
|
|
176 | |
|
Listing and Configuring Exceptions |
|
|
181 | |
|
Notes on Exception Handling |
|
|
182 | |
|
|
183 | |
|
CHAPTER 8: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING |
|
|
185 | |
|
What Is Object-Oriented Programming? |
|
|
186 | |
|
|
187 | |
|
|
188 | |
|
|
189 | |
|
|
189 | |
|
The Life Cycle of an Object |
|
|
190 | |
|
|
190 | |
|
|
191 | |
|
Static and Instance Class Members |
|
|
191 | |
|
|
191 | |
|
|
192 | |
|
|
192 | |
|
|
193 | |
|
|
194 | |
|
|
194 | |
|
|
196 | |
|
|
197 | |
|
Relationships Between Objects |
|
|
198 | |
|
|
198 | |
|
|
199 | |
|
|
200 | |
|
|
200 | |
|
Reference Types Versus Value Types |
|
|
201 | |
|
OOP in Windows Applications |
|
|
201 | |
|
|
204 | |
|
CHAPTER 9: DEFINING CLASSES |
|
|
209 | |
|
|
209 | |
|
|
212 | |
|
|
215 | |
|
Constructors and Destructors |
|
|
217 | |
|
Constructor Execution Sequence |
|
|
218 | |
|
|
222 | |
|
|
222 | |
|
|
224 | |
|
|
226 | |
|
|
227 | |
|
|
229 | |
|
Interfaces Versus Abstract Classes |
|
|
232 | |
|
|
235 | |
|
Shallow Copying Versus Deep Copying |
|
|
237 | |
|
|
237 | |
|
CHAPTER 10: DEFINING CLASS MEMBERS |
|
|
241 | |
|
|
241 | |
|
|
242 | |
|
|
242 | |
|
|
244 | |
|
Adding Members from a Class Diagram |
|
|
249 | |
|
|
250 | |
|
|
251 | |
|
|
252 | |
|
|
252 | |
|
|
253 | |
|
Additional Class Member Topics |
|
|
253 | |
|
Hiding Base Class Methods |
|
|
254 | |
|
Calling Overridden or Hidden Base Class Methods |
|
|
255 | |
|
|
256 | |
|
|
257 | |
|
|
257 | |
|
Implementing Interfaces in Classes |
|
|
258 | |
|
Explicit Interface Member Implementation |
|
|
260 | |
|
Adding Property Accessors with Nonpublic Accessibility |
|
|
260 | |
|
Partial Class Definitions |
|
|
261 | |
|
Partial Method Definitions |
|
|
262 | |
|
|
264 | |
|
|
264 | |
|
|
264 | |
|
|
265 | |
|
Writing the Class Library |
|
|
265 | |
|
Adding the Suit and Rank Enumerations |
|
|
266 | |
|
|
268 | |
|
|
269 | |
|
A Client Application for the Class Library |
|
|
272 | |
|
The Call Hierarchy Window |
|
|
274 | |
|
|
275 | |
|
CHAPTER 11: COLLECTIONS, COMPARISONS, AND CONVERSIONS |
|
|
277 | |
|
|
278 | |
|
|
278 | |
|
|
284 | |
|
|
286 | |
|
Adding a Cards Collection to CardLib |
|
|
288 | |
|
Keyed Collections and 'Dictionary |
|
|
291 | |
|
|
293 | |
|
Iterators and Collections |
|
|
297 | |
|
|
299 | |
|
Adding Deep Copying to CardLib |
|
|
301 | |
|
|
303 | |
|
|
303 | |
|
|
303 | |
|
|
305 | |
|
|
308 | |
|
|
308 | |
|
Adding Operator Overloads to CardLib |
|
|
313 | |
|
The IComparable and IComparer Interfaces |
|
|
318 | |
|
Sorting Collections Using the 'Comparable and IComparer Interfaces |
|
|
320 | |
|
|
324 | |
|
Overloading Conversion Operators |
|
|
324 | |
|
|
326 | |
|
|
327 | |
|
|
331 | |
|
|
332 | |
|
|
333 | |
|
|
333 | |
|
Operators and Nuliable Types |
|
|
334 | |
|
|
336 | |
|
The System.Collections.Generics Namespace |
|
|
340 | |
|
|
341 | |
|
Sorting and Searching Generic Lists |
|
|
343 | |
|
|
349 | |
|
Modifying CardLib to Use a Generic Collection Class |
|
|
350 | |
|
|
351 | |
|
|
351 | |
|
|
354 | |
|
|
354 | |
|
Inheriting from Generic Classes |
|
|
361 | |
|
|
362 | |
|
|
363 | |
|
Defining Generic Interfaces |
|
|
364 | |
|
|
364 | |
|
Defining Generic Delegates |
|
|
366 | |
|
|
366 | |
|
|
367 | |
|
|
368 | |
|
|
369 | |
|
CHAPTER 13: ADDITIONAL OOP TECHNIQUES |
|
|
373 | |
|
The :: Operator and the Global Namespace Qualifier |
|
|
373 | |
|
|
375 | |
|
Adding Custom Exceptions to CardLib |
|
|
375 | |
|
|
377 | |
|
|
377 | |
|
|
378 | |
|
|
380 | |
|
Multipurpose Event Handlers |
|
|
385 | |
|
The EventHandler and Generic EventHandler<T> Types |
|
|
388 | |
|
Return Values and Event Handlers |
|
|
388 | |
|
|
389 | |
|
Expanding and Using CardLib |
|
|
389 | |
|
A Card Game Client for CardLib |
|
|
390 | |
|
|
398 | |
|
CHAPTER 14: C.* LANGUAGE ENHANCEMENTS |
|
|
401 | |
|
|
402 | |
|
|
402 | |
|
|
404 | |
|
|
407 | |
|
|
409 | |
|
|
413 | |
|
|
414 | |
|
IDynamicMetaObjectProvider |
|
|
417 | |
|
Advanced Method Parameters |
|
|
418 | |
|
|
418 | |
|
Optional Parameter Values |
|
|
419 | |
|
|
420 | |
|
|
420 | |
|
Named and Optional Parameter Guidelines |
|
|
424 | |
|
|
424 | |
|
|
429 | |
|
|
429 | |
|
Lambda Expressions for Anonymous Methods |
|
|
430 | |
|
Lambda Expression Parameters |
|
|
434 | |
|
Lambda Expression Statement Bodies |
|
|
434 | |
|
Lambda Expressions As Delegates and Expression Trees |
|
|
435 | |
|
Lambda Expressions and Collections |
|
|
436 | |
|
|
439 | |
PART II: WINDOWS PROGRAMMING |
|
|
CHAPTER 15: BASIC WINDOWS PROGRAMMING |
|
|
447 | |
|
|
448 | |
|
|
448 | |
|
Anchoring, Docking, and Snapping Controls |
|
|
449 | |
|
Anchor and Dock Properties |
|
|
450 | |
|
|
451 | |
|
|
453 | |
|
|
453 | |
|
|
453 | |
|
Adding the Event Handlers |
|
|
455 | |
|
The Label and LinkLabel Controls |
|
|
456 | |
|
|
457 | |
|
|
457 | |
|
|
458 | |
|
Adding the Event Handlers |
|
|
460 | |
|
The RadioButton and CheckBox Controls |
|
|
464 | |
|
|
465 | |
|
|
465 | |
|
|
466 | |
|
|
466 | |
|
|
466 | |
|
|
470 | |
|
|
470 | |
|
|
472 | |
|
The ListBox and CheckedListBox Controls |
|
|
477 | |
|
|
477 | |
|
|
478 | |
|
|
478 | |
|
|
481 | |
|
|
481 | |
|
|
481 | |
|
|
481 | |
|
|
484 | |
|
|
484 | |
|
|
484 | |
|
|
491 | |
|
|
491 | |
|
Working with the TabControl |
|
|
492 | |
|
|
494 | |
|
CHAPTER 16: ADVANCED WINDOWS FORMS FEATURES |
|
|
497 | |
|
|
498 | |
|
|
498 | |
|
Using the MenuStrip Control |
|
|
498 | |
|
|
499 | |
|
Properties of the ToolStripMenultem |
|
|
501 | |
|
Adding Functionality to Menus |
|
|
501 | |
|
|
503 | |
|
|
504 | |
|
|
504 | |
|
|
507 | |
|
|
509 | |
|
StatusStripStatusLabel Properties |
|
|
510 | |
|
|
512 | |
|
Building MDI Applications |
|
|
513 | |
|
|
522 | |
|
|
524 | |
|
Adding the Event Handlers |
|
|
525 | |
|
|
527 | |
|
Extending the LabelTextbox Control |
|
|
527 | |
|
|
528 | |
|
Adding More Event Handlers |
|
|
529 | |
|
Adding a Custom Event Handler |
|
|
529 | |
|
|
530 | |
|
CHAPTER 17: DEPLOYING WINDOWS APPLICATIONS |
|
|
533 | |
|
|
533 | |
|
|
534 | |
|
Creating the ClickOnce Deployment |
|
|
534 | |
|
Installing the Application with ClickOnce |
|
|
543 | |
|
Creating and Using Updates of the Application |
|
|
545 | |
|
Visual Studio Setup and Deployment Project Types |
|
|
546 | |
|
Microsoft Windows Installer Architecture |
|
|
547 | |
|
|
548 | |
|
Advantages of the Windows Installer |
|
|
549 | |
|
Creating an Installation Package for the MDI Editor |
|
|
550 | |
|
Planning the Installation |
|
|
550 | |
|
|
552 | |
|
|
553 | |
|
|
553 | |
|
|
554 | |
|
|
556 | |
|
|
556 | |
|
Adding Items to Special Folders |
|
|
557 | |
|
|
557 | |
|
|
559 | |
|
|
560 | |
|
|
561 | |
|
|
561 | |
|
|
563 | |
|
|
565 | |
|
|
566 | |
|
|
566 | |
|
|
566 | |
|
|
567 | |
|
|
568 | |
|
Select Installation Folder |
|
|
568 | |
|
|
568 | |
|
|
569 | |
|
|
570 | |
|
|
571 | |
|
|
571 | |
|
|
571 | |
|
|
571 | |
PART III: WEB PROGRAMMING |
|
|
CHAPTER 18: ASP.NET WEB PROGRAMMING |
|
|
577 | |
|
Overview of Web Applications |
|
|
578 | |
|
|
578 | |
|
|
578 | |
|
|
587 | |
|
|
588 | |
|
|
593 | |
|
|
597 | |
|
|
600 | |
|
Client-Side State Management |
|
|
601 | |
|
|
601 | |
|
|
602 | |
|
Server-Side State Management |
|
|
603 | |
|
|
603 | |
|
|
605 | |
|
|
605 | |
|
|
606 | |
|
|
611 | |
|
|
616 | |
|
Authentication and Authorization |
|
|
619 | |
|
Authentication Configuration |
|
|
619 | |
|
|
623 | |
|
Reading from and Writing to a SQL Server Database |
|
|
626 | |
|
|
634 | |
|
|
637 | |
|
Where to Use Web Services |
|
|
637 | |
|
A Hotel Travel Agency Application Scenario |
|
|
638 | |
|
A Book Distributor Application Scenario |
|
|
638 | |
|
|
639 | |
|
|
639 | |
|
Web Services Architecture |
|
|
640 | |
|
Calling Methods and the Web Services Description Language |
|
|
640 | |
|
|
641 | |
|
|
642 | |
|
Web Services and the .NET Framework |
|
|
642 | |
|
|
643 | |
|
|
643 | |
|
|
643 | |
|
WebServiceBInding Attribute |
|
|
644 | |
|
|
645 | |
|
|
645 | |
|
Alternative Client Protocols |
|
|
645 | |
|
Creating a Simple ASP.NET Web Service |
|
|
645 | |
|
|
648 | |
|
|
649 | |
|
Implementing a Windows Client |
|
|
649 | |
|
Calling the Service Asynchronously |
|
|
655 | |
|
Implementing an ASP.NET Client |
|
|
658 | |
|
|
659 | |
|
|
662 | |
|
CHAPTER 20: DEPLOYING WEB APPLICATIONS |
|
|
665 | |
|
Internet Information Services |
|
|
665 | |
|
|
666 | |
|
|
669 | |
|
Publishing a Web Application |
|
|
672 | |
|
|
675 | |
|
|
675 | |
|
Installing the Web Application |
|
|
677 | |
|
|
678 | |
PART IV: DATA ACCESS |
|
|
CHAPTER 21: FILE SYSTEM DATA |
|
|
683 | |
|
|
683 | |
|
The Classes for Input and Output |
|
|
684 | |
|
The File and Directory Classes |
|
|
686 | |
|
|
687 | |
|
|
689 | |
|
Path Names and Relative Paths |
|
|
690 | |
|
|
690 | |
|
|
691 | |
|
|
692 | |
|
|
695 | |
|
|
697 | |
|
|
699 | |
|
|
701 | |
|
|
702 | |
|
Reading and Writing Compressed Files |
|
|
706 | |
|
|
710 | |
|
Monitoring the File System |
|
|
715 | |
|
|
722 | |
|
|
725 | |
|
|
726 | |
|
|
726 | |
|
|
727 | |
|
|
728 | |
|
Structure of an XML Document |
|
|
728 | |
|
|
729 | |
|
Well-Formed and Valid XML |
|
|
730 | |
|
|
730 | |
|
|
730 | |
|
|
731 | |
|
Using XML in Your Application |
|
|
734 | |
|
XML Document Object Model |
|
|
734 | |
|
|
735 | |
|
|
735 | |
|
Changing the Values of Nodes |
|
|
739 | |
|
|
744 | |
|
|
745 | |
|
|
749 | |
|
CHAPTER 23: INTRODUCTION TO LINQ |
|
|
753 | |
|
|
754 | |
|
Declaring a Variable for Results Using the var Keyword |
|
|
756 | |
|
Specify Data Source: from Clause |
|
|
756 | |
|
Specify Condition: where Clause |
|
|
757 | |
|
Select Items: select Clause |
|
|
757 | |
|
Finishing Up: Using the foreach Loop |
|
|
757 | |
|
|
757 | |
|
Using the LINQ Method Syntax |
|
|
758 | |
|
|
758 | |
|
Query Syntax versus Method Syntax |
|
|
758 | |
|
|
760 | |
|
|
761 | |
|
Ordering Using Method Syntax |
|
|
762 | |
|
Querying a Large Data Set |
|
|
764 | |
|
|
766 | |
|
|
770 | |
|
Projection: Creating New Objects in Queries |
|
|
774 | |
|
Projection: Method Syntax |
|
|
776 | |
|
|
776 | |
|
|
777 | |
|
Ordering by Multiple Levels |
|
|
779 | |
|
Multi-Level Ordering Method Syntax: ThenBy |
|
|
781 | |
|
|
781 | |
|
|
783 | |
|
|
785 | |
|
|
787 | |
|
|
790 | |
|
|
791 | |
|
CHAPTER 24: APPLYING LINQ |
|
|
795 | |
|
|
795 | |
|
Using LINQ with Databases |
|
|
796 | |
|
Installing SQL Server and the Northwind Sample Data |
|
|
797 | |
|
Installing SQL Server Express 2008 |
|
|
797 | |
|
Installing the Northwind Sample Database |
|
|
797 | |
|
First LINQ to Database Query |
|
|
798 | |
|
Navigating Database Relationships |
|
|
801 | |
|
|
804 | |
|
LINQ to XML Functional Constructors |
|
|
804 | |
|
Constructing XML Element Text with Strings |
|
|
808 | |
|
Saving and Loading an XML Document |
|
|
808 | |
|
Loading XML from a String |
|
|
811 | |
|
Contents of a Saved XML Document |
|
|
811 | |
|
Working with XML Fragments |
|
|
812 | |
|
Generating XML from Databases |
|
|
814 | |
|
How to Query an XML Document |
|
|
817 | |
|
Using LINO to XML Query Members |
|
|
818 | |
|
|
818 | |
|
|
819 | |
|
|
821 | |
|
|
823 | |
PART V: ADDITIONAL TECHNIQUES |
|
|
CHAPTER 25: WINDOWS PRESENTATION FOUNDATION |
|
|
829 | |
|
|
830 | |
|
|
830 | |
|
|
833 | |
|
Anatomy of a Basic WPF Application |
|
|
834 | |
|
|
845 | |
|
|
845 | |
|
|
845 | |
|
|
846 | |
|
|
846 | |
|
|
847 | |
|
Mixing Property Element Syntax and Content Syntax |
|
|
847 | |
|
|
848 | |
|
Desktop and Web Applications |
|
|
848 | |
|
|
849 | |
|
|
849 | |
|
|
850 | |
|
|
852 | |
|
|
852 | |
|
|
858 | |
|
|
858 | |
|
|
859 | |
|
Alignment, Margins, Padding, and Dimensions |
|
|
859 | |
|
|
860 | |
|
|
860 | |
|
|
861 | |
|
|
863 | |
|
|
866 | |
|
|
868 | |
|
|
868 | |
|
|
869 | |
|
|
869 | |
|
|
874 | |
|
|
875 | |
|
Timelines without Key Frames |
|
|
876 | |
|
Timelines with Key Frames |
|
|
877 | |
|
Static and Dynamic Resources |
|
|
878 | |
|
|
878 | |
|
|
878 | |
|
Referencing Style Resources |
|
|
879 | |
|
|
884 | |
|
|
884 | |
|
Implementing Dependency Properties |
|
|
884 | |
|
|
895 | |
|
CHAPTER 26: WINDOWS COMMUNICATION FOUNDATION |
|
|
899 | |
|
|
900 | |
|
|
901 | |
|
WCF Communication Protocols |
|
|
901 | |
|
Addresses, Endpoints, and Bindings |
|
|
902 | |
|
|
904 | |
|
|
905 | |
|
|
905 | |
|
|
906 | |
|
|
906 | |
|
|
914 | |
|
Defining WCF Service Contracts |
|
|
917 | |
|
|
918 | |
|
|
918 | |
|
|
919 | |
|
|
920 | |
|
|
920 | |
|
|
925 | |
|
|
933 | |
|
CHAPTER 27: WINDOWS WORKFLOW FOUNDATION |
|
|
935 | |
|
|
936 | |
|
|
937 | |
|
|
938 | |
|
|
938 | |
|
|
938 | |
|
|
939 | |
|
|
944 | |
|
|
946 | |
|
|
952 | |
|
|
953 | |
|
|
955 | |
APPENDIX A: EXERCISE SOLUTIONS |
|
957 | |
INDEX |
|
1009 | |