Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Wednesday, January 18, 2012

C-sharp 2.0 The Complete Reference, Second Edition






C# 2.0: The Complete Reference, Second Edition
byHerbert Schildt
McGraw-Hill/Osborne 2006 (912 pages)
ISBN:0072262095
With carefully crafted explanations, insider tips, and hundreds of examples, this book offers in-depth coverage of all aspects of C#, including its keywords, syntax, and core libraries.





Table of Contents
C# 2.0—The Complete Reference, Second Edition
Preface
Part I - The C# Language
Chapter 1 - The Creation of C#
Chapter 2 - An Overview of C#
Chapter 3 - Data Types, Literals, and Variables
Chapter 4 - Operators
Chapter 5 - Program Control Statements
Chapter 6 - Introducing Classes and Objects
Chapter 7 - Arrays and Strings
Chapter 8 - A Closer Look at Methods and Classes
Chapter 9 - Operator Overloading
Chapter 10 - Indexers and Properties
Chapter 11 - Inheritance
Chapter 12 - Interfaces, Structures, and Enumerations
Chapter 13 - Exception Handling
Chapter 14 - Using I/O
Chapter 15 - Delegates and Events
Chapter 16 - Namespaces, the Preprocessor, and Assemblies
Chapter 17 - Runtime Type ID, Reflection, and Attributes
Chapter 18 - Generics
Chapter 19 - Unsafe Code, Pointers, Nullable Types, and Miscellaneous Topics
Part II - Exploring the C# Library
Chapter 20 - Exploring the System Namespace
Chapter 21 - Strings and Formatting
Chapter 22 - Multithreaded Programming
Chapter 23 - Collections, Enumerators, and Iterators
Chapter 24 - Networking Through the Internet
Part III - Applying C#
Chapter 25 - Building Components
Chapter 26 - Creating Form-Based Windows Applications
Chapter 27 - A Recursive-Descent Expression Parser
Appendix A - XML Comment Quick Reference
Index
List of Figures
List of Tables


Other C# Books
Other Programming Language Books
Download

Saturday, December 17, 2011

C# 3.0 The Complete Reference






Contents at a Glance
Part I The C# Language
1 The Creation of C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 An Overview of C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3 Data Types, Literals, and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5 Program Control Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6 Introducing Classes and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
7 Arrays and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
8 A Closer Look at Methods and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
9 Operator Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
10 Indexers and Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
11 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
12 Interfaces, Structures, and Enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
13 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
14 Using I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
15 Delegates, Events, and Lambda Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 399
16 Namespaces, the Preprocessor, and Assemblies . . . . . . . . . . . . . . . . . . . . . . 437
17 Runtime Type ID, Refl ection, and Attributes . . . . . . . . . . . . . . . . . . . . . . . . 459
18 Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
19 LINQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
20 Unsafe Code, Pointers, Nullable Types, and Miscellaneous Topics . . . . . 585
Part II Exploring the C# Library
21 Exploring the System Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
22 Strings and Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
23 Multithreaded Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
24 Collections, Enumerators, and Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749
25 Networking Through the Internet Using System.Net . . . . . . . . . . . . . . . . . 821
26 Use System.Windows.Forms to Create Form-Based Windows
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847
A Documentation Comment Quick Reference . . . . . . . . . . . . . . . . . . . . . . . . . 867
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 871

Another C# Books
Another Programming Language Books
Download

C# 2.0 The Complete Reference






By Herbert Schildt
Publisher: McGraw-Hill Osborne Media
This comprehensive volume is fully updated for C# 2.0 -- the newest version of Microsoft's revolutionary programming language.The changes found in C# 2.0 bring Java-like power to millions of Windows programmers worldwide. With expertly crafted explanations, insider tips, and hundreds of examples, this book fully explains every aspect of C# 2.0. Written in the clear, uncompromising style that has made master programming author Herb Schildt the choice of millions, the book covers all the new and existing features of this major programming language.
Subjects



Part I - The C# Language

Chapter 1 The Creation of C#

Chapter 2 An Overview of C#

Chapter 3 Data Types, Literals, and Variables

Chapter 4 Operators

Chapter 5 Program Control Statements

Chapter 6 Introducing Classes and Objects

Chapter 7 Arrays and Strings

Chapter 8 A Closer Look at Methods and Classes

Chapter 9 Operator Overloading

Chapter 10 Indexers and Properties

Chapter 11 Inheritance

Chapter 12 Interfaces, Structures, and Enumerations

Chapter 13 Exception Handling

Chapter 14 Using I/O

Chapter 15 Delegates and Events

Chapter 16 Namespaces, the Preprocessor, and Assemblies

Chapter 17 Runtime Type ID, Reflection, and Attributes

Chapter 18 Generics

Chapter 19 Unsafe Code, Pointers, Nullable Types, and Miscellaneous Topics

Part II - Exploring the C# Library

Chapter 20 Exploring the System Namespace

Chapter 21 Strings and Formatting

Chapter 22 Multithreaded Programming

Chapter 23 Collections, Enumerators, and Iterators

Chapter 24 Networking Through the Internet

Part III - Applying

Chapter 25 Building Components

Chapter 26 Creating Form-Based Windows Applications

Chapter 27 A Recursive-Descent Expression Parser

Another C# Books
Another Programming Language Books
Download

Thursday, December 15, 2011

C# How To Program






Contents
Contents viii
Illustrations xix
Preface xxxviii
1 Introduction to Computers, the Internet,
the Web and C# 1
1.1 Introduction 2
1.2 What Is a Computer? 3
1.3 Computer Organization 3
1.4 Evolution of Operating Systems 4
1.5 Personal Computing, Distributed Computing and Client/Server Computing 5
1.6 Machine Languages, Assembly Languages and High-level Languages 6
1.7 C, C++, Visual Basic .NET and Java™ 7
1.8 C# 9
1.9 Other High-level Languages 10
1.10 Structured Programming 10
1.11 Key Software Trend: Object Technology 11
1.12 Hardware Trends 13
1.13 History of the Internet and World Wide Web 13
1.14 World Wide Web Consortium (W3C) 15
1.15 Extensible Markup Language (XML) 15
1.16 Introduction to Microsoft .NET 16
1.17 .NET Framework and the Common Language Runtime 18
1.18 Tour of the Book 20
1.19 Internet and World Wide Web Resources 29Contents IX
2 Introduction to the Visual Studio .NET IDE 33
2.1 Introduction 34
2.2 Visual Studio .NET Integrated Development Environment (IDE) Overview 34
2.3 Menu Bar and Toolbar 37
2.4 Visual Studio .NET Windows 39
2.4.1 Solution Explorer 39
2.4.2 Toolbox 40
2.4.3 Properties Window 42
2.5 Using Help 42
2.6 Simple Program: Displaying Text and an Image 44
3 Introduction to C# Programming 59
3.1 Introduction 60
3.2 Simple Program: Printing a Line of Text 60
3.3 Another Simple Program: Adding Integers 71
3.4 Memory Concepts 75
3.5 Arithmetic 76
3.6 Decision Making: Equality and Relational Operators 80
4 Control Structures: Part 1 94
4.1 Introduction 95
4.2 Algorithms 95
4.3 Pseudocode 96
4.4 Control Structures 96
4.5 if Selection Structure 99
4.6 if/else Selection Structure 100
4.7 while Repetition Structure 105
4.8 Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition) 106
4.9 Formulating Algorithms with Top-Down, Stepwise Refinement:
Case Study 2 (Sentinel-Controlled Repetition) 109
4.10 Formulating Algorithms with Top-Down, Stepwise Refinement:
Case Study 3 (Nested Control Structures) 116
4.11 Assignment Operators 120
4.12 Increment and Decrement Operators 121
4.13 Introduction to Windows Application Programming 124
5 Control Structures: Part 2 139
5.1 Introduction 140
5.2 Essentials of Counter-Controlled Repetition 140
5.3 for Repetition Structure 142
5.4 Examples Using the for Structure 146
5.5 switch Multiple-Selection Structure 152
5.6 do/while Repetition Structure 156
5.7 Statements break and continue 158
5.8 Logical and Conditional Operators 160
5.9 Structured-Programming Summary 166X Contents
6 Methods 178
6.1 Introduction 179
6.2 Program Modules in C# 179
6.3 Math Class Methods 181
6.4 Methods 181
6.5 Method Definitions 183
6.6 Argument Promotion 193
6.7 C# Namespaces 195
6.8 Value Types and Reference Types 196
6.9 Passing Arguments: Pass-by-Value vs. Pass-by-Reference 197
6.10 Random-Number Generation 200
6.11 Example: Game of Chance 207
6.12 Duration of Variables 212
6.13 Scope Rules 212
6.14 Recursion 215
6.15 Example Using Recursion: The Fibonacci Series 219
6.16 Recursion vs. Iteration 222
6.17 Method Overloading 223
7 Arrays 236
7.1 Introduction 237
7.2 Arrays 237
7.3 Declaring and Allocating Arrays 239
7.4 Examples Using Arrays 240
7.4.1 Allocating an Array and Initializing Its Elements 240
7.4.2 Totaling the Elements of an Array 242
7.4.3 Using Histograms to Display Array Data Graphically 243
7.4.4 Using the Elements of an Array as Counters 244
7.4.5 Using Arrays to Analyze Survey Results 247
7.5 Passing Arrays to Methods 250
7.6 Passing Arrays by Value and by Reference 253
7.7 Sorting Arrays 257
7.8 Searching Arrays: Linear Search and Binary Search 260
7.8.1 Searching an Array with Linear Search 260
7.8.2 Searching a Sorted Array with Binary Search 261
7.9 Multiple-Subscripted Arrays 265
7.10 foreach Repetition Structure 272
8 Object-Based Programming 280
8.1 Introduction 281
8.2 Implementing a Time Abstract Data Type with a Class 282
8.3 Class Scope 290
8.4 Controlling Access to Members 290
8.5 Initializing Class Objects: Constructors 292
8.6 Using Overloaded Constructors 293
8.7 Properties 297
8.8 Composition: Objects References as Instance Variables of Other Classes 306
8.9 Using the this Reference 309
8.10 Garbage Collection 311
8.11 static Class Members 312
8.12 const and readonly Members 317
8.13 Indexers 319
8.14 Data Abstraction and Information Hiding 326
8.15 Software Reusability 327
8.16 Namespaces and Assemblies 328
8.17 Class View and Object Browser 333
9 Object-Oriented Programming: Inheritance 342
9.1 Introduction 343
9.2 Base Classes and Derived Classes 344
9.3 protected and internal Members 347
9.4 Relationship between Base Classes and Derived Classes 347
9.5 Case Study: Three-Level Inheritance Hierarchy 368
9.6 Constructors and Destructors in Derived Classes 371
9.7 Software Engineering with Inheritance 377
10 Object-Oriented Programming: Polymorphism 382
10.1 Introduction 383
10.2 Derived-Class-Object to Base-Class-Object Conversion 383
10.3 Type Fields and switch Statements 390
10.4 Polymorphism Examples 391
10.5 Abstract Classes and Methods 392
10.6 Case Study: Inheriting Interface and Implementation 394
10.7 sealed Classes and Methods 402
10.8 Case Study: Payroll System Using Polymorphism 403
10.9 Case Study: Creating and Using Interfaces 413
10.10 Delegates 425
10.11 Operator Overloading 430
11 Exception Handling 438
11.1 Introduction 439
11.2 Exception Handling Overview 440
11.3 Example: DivideByZeroException 443
11.4 .NET Exception Hierarchy 448
11.5 finally Block 449
11.6 Exception Properties 457
11.7 Programmer-Defined Exception Classes 462
11.8 Handling Overflows with Operators checked and unchecked 466
12 Graphical User Interface Concepts: Part 1 474
12.1 Introduction 475
12.2 Windows Forms 476
12.3 Event-Handling Model 479
12.3.1 Basic Event Handling 480
12.4 Control Properties and Layout 484
12.5 Labels, TextBoxes and Buttons 488
12.6 GroupBoxes and Panels 495
12.7 CheckBoxes and RadioButtons 498
12.8 PictureBoxes 507
12.9 Mouse Event Handling 509
12.10 Keyboard Event Handling 511
13 Graphical User Interfaces Concepts:
Part 2 520
13.1 Introduction 521
13.2 Menus 521
13.3 LinkLabels 530
13.4 ListBoxes and CheckedListBoxes 534
13.4.1 ListBoxes 537
13.4.2 CheckedListBoxes 539
13.5 ComboBoxes 542
13.6 TreeViews 547
13.7 ListViews 553
13.8 Tab Control 560
13.9 Multiple-Document-Interface (MDI) Windows 565
13.10 Visual Inheritance 574
13.11 User-Defined Controls 578
14 Multithreading 590
14.1 Introduction 591
14.2 Thread States: Life Cycle of a Thread 592
14.3 Thread Priorities and Thread Scheduling 594
14.4 Thread Synchronization and Class Monitor 599
14.5 Producer/Consumer Relationship without Thread Synchronization 601
14.6 Producer/Consumer Relationship with Thread Synchronization 607
14.7 Producer/Consumer Relationship: Circular Buffer 616
15 Strings, Characters and Regular Expressions 632
15.1 Introduction 633
15.2 Fundamentals of Characters and Strings 633
15.3 String Constructors 635
15.4 String Indexer, Length Property and CopyTo Method 636
15.5 Comparing Strings 638
15.6 String Method GetHashCode 642
15.7 Locating Characters and Substrings in Strings 643
15.8 Extracting Substrings from Strings 646
15.9 Concatenating Strings 647
15.10 Miscellaneous String Methods 648
15.11 Class StringBuilder 650
15.12 StringBuilder Indexer, Length and Capacity Properties,
and EnsureCapacity Method 652
15.13 StringBuilder Append and AppendFormat Methods 654
15.14 StringBuilder Insert, Remove and Replace Methods 658
15.15 Char Methods 661
15.16 Card Shuffling and Dealing Simulation 664
15.17 Regular Expressions and Class Regex 668
16 Graphics and Multimedia 684
16.1 Introduction 685
16.2 Graphics Contexts and Graphics Objects 687
16.3 Color Control 688
16.4 Font Control 696
16.5 Drawing Lines, Rectangles and Ovals 701
16.6 Drawing Arcs 704
16.7 Drawing Polygons and Polyli]nes 707
16.8 Advanced Graphics Capabilities 711
16.9 Introduction to Multimedia 717
16.10 Loading, Displaying and Scaling Images 718
16.11 Animating a Series of Images 720
16.12 Windows Media Player 733
16.13 Microsoft Agent 736
17 Files and Streams 757 6
17.1 Introduction 757
17.2 Data Hierarchy 757
17.3 Files and Streams 759
17.4 Classes File and Directory 761
17.5 Creating a Sequential-Access File 771
17.6 Reading Data from a Sequential-Access File 783
17.7 Random-Access Files 794
17.8 Creating a Random-Access File 798
17.9 Writing Data Randomly to a Random-Access File 802
17.10 Reading Data Sequentially from a Random-Access File 807
17.11 Case Study: A Transaction-Processing Program 812
18 Extensible Markup Language (XML) 838
18.1 Introduction 839
18.2 XML Documents 839
18.3 XML Namespaces 844
18.4 Document Object Model (DOM) 847
18.5 Document Type Definitions (DTDs), Schemas and Validation 865
18.5.1 Document Type Definitions 866
18.5.2 Microsoft XML Schemas 869
18.5.3 W3C XML Schema 872
18.5.4 Schema Validation in C# 873
18.6 Extensible Stylesheet Language and XslTransform 877
18.7 Microsoft BizTalk™ 884
18.8 Internet and World Wide Web Resources 887
19 Database, SQL and
ADO .NET 895
19.1 Introduction 896
19.2 Relational Database Model 897
19.3 Relational Database Overview: Books Database 898
19.4 Structured Query Language (SQL) 905
19.4.1 Basic SELECT Query 905
19.4.2 WHERE Clause 906
19.4.3 ORDER BY Clause 909
19.4.4 Merging Data from Multiple Tables: INNER JOIN 912
19.4.5 Joining Data from Tables Authors, AuthorISBN,
Titles and Publishers 914
19.4.6 INSERT Statement 917
19.4.7 UPDATE Statement 918
19.4.8 DELETE Statement 919
19.5 ADO .NET Object Model 920
19.6 Programming with ADO .NET: Extracting Information from a DBMS 921
19.6.1 Connecting to and Querying an Access Data Source 921
19.6.2 Querying the Books Database 928
19.7 Programming with ADO.NET: Modifying a DBMS 930
19.8 Reading and Writing XML Files 938
20 ASP .NET, Web Forms and Web Controls 948
20.1 Introduction 949
20.2 Simple HTTP Transaction 950
20.3 System Architecture 952
20.4 Creating and Running a Simple Web Form Example 953
20.5 Web Controls 966
20.5.1 Text and Graphics Controls 967
20.5.2 AdRotator Control 971
20.5.3 Validation Controls 976
20.6 Session Tracking 987
20.6.1 Cookies 988
20.6.2 Session Tracking with HttpSessionState 997
20.7 Case Study: Online Guest Book 1006
20.8 Case Study: Connecting to a Database in ASP .NET 1013
20.9 Tracing 1027
20.10 Internet and World Wide Web Resources 1030
21 ASP .NET and Web Services 1039
21.1 Introduction 1040
21.2 Web Services 1041
21.3 Simple Object Access Protocol (SOAP) and Web Services 1044
21.4 Publishing and Consuming Web Services 1046
21.5 Session Tracking in Web Services 1062
21.6 Using Web Forms and Web Services 1075
21.7 Case Study: Temperature Information Application 1081
21.8 User-Defined Types in Web Services 1091
22 Networking: Streams-Based Sockets and Datagrams1106
22.1 Introduction 1107
22.2 Establishing a Simple Server (Using Stream Sockets) 1108
22.3 Establishing a Simple Client (Using Stream Sockets) 1110
22.4 Client/Server Interaction with Stream-Socket Connections 1111
22.5 Connectionless Client/Server Interaction with Datagrams 1120
22.6 Client/Server Tic-Tac-Toe Using a Multithreaded Server 1125
23 Data Structures and Collections 1145
23.1 Introduction 1146
23.2 Self-Referential Classes 1146
23.3 Linked Lists 1148
23.4 Stacks 1160
23.5 Queues 1165
23.6 Trees 1168
23.6.1 Binary Search Tree of Integer Values 1170
23.6.2 Binary Search Tree of IComparable Objects 1177
23.7 Collection Classes 1185
23.7.1 Class Array 1185
23.7.2 Class ArrayList 1188
23.7.3 Class Stack 1194
23.7.4 Class Hashtable 1198
24 Accessibility 1212
24.1 Introduction 1213
24.2 Regulations and Resources 1214
24.3 Web Accessibility Initiative 1216
24.4 Providing Alternatives for Images 1216
24.5 Maximizing Readability by Focusing on Structure 1218
24.6 Accessibility in Visual Studio .NET 1218
24.6.1 Enlarging Toolbar Icons 1219
24.6.2 Enlarging the Text 1220
24.6.3 Modifying the Toolbox 1221
24.6.4 Modifying the Keyboard 1221
24.6.5 Rearranging Windows 1222
24.7 Accessibility in C# 1224
24.8 Accessibility in XHTML Tables 1230
24.9 Accessibility in XHTML Frames 1234
24.10 Accessibility in XML 1235
24.11 Using Voice Synthesis and Recognition with VoiceXML™ 1235
24.12 CallXML™ 1243
24.13 JAWS® for Windows 1248
24.14 Other Accessibility Tools 1249
24.15 Accessibility in Microsoft® Windows® 2000 1251
24.15.1 Tools for People with Visual Impairments 1252
24.15.2 Tools for People with Hearing Impairments 1254
24.15.3 Tools for Users Who Have Difficulty Using the Keyboard 1255
24.15.4 Microsoft Narrator 1258
24.15.5 Microsoft On-Screen Keyboard 1261
24.15.6 Accessibility Features in Microsoft Internet Explorer 5.5 1262
24.16 Internet and World Wide Web Resources 1264
A Operator Precedence Chart 1273
B Number Systems (on CD) 1275
B.1 Introduction 1276
B.2 Abbreviating Binary Numbers as Octal Numbers and
Hexadecimal Numbers 1279
B.3 Converting Octal Numbers and Hexadecimal Numbers
to Binary Numbers 1281
B.4 Converting from Binary, Octal or Hexadecimal to Decimal 1281
B.5 Converting from Decimal to Binary, Octal, or Hexadecimal 1282
B.6 Negative Binary Numbers: Two’s Complement Notation 1283
C Career Opportunities (on CD) 1289
C.1 Introduction 1290
C.2 Resources for the Job Seeker 1291
C.3 Online Opportunities for Employers 1292
C.4 Recruiting Services 1297
C.5 Career Sites 1298
C.6 Internet and World Wide Web Resources 1303
D Visual Studio .NET Debugger 1311
D.1 Introduction 1312
D.2 Breakpoints 1313
D.3 Examining Data 1315
D.4 Program Control 1318
D.5 Additional Method Debugging Capabilities 1322
D.6 Additional Class Debugging Capabilities 1324
E Generating Documentation in Visual Studio (on CD) 1329
E.1 Introduction 1330
E.2 Documentation Comments 1330
E.3 Documenting C# Source Code 1331
E.4 Creating Comment Web Pages 1339
E.5 Creating XML Documentation Files 1341
F ASCII Character Set 1348
G Unicode® (on CD) 1349
G.1 Introduction 1350
G.2 Unicode Transformation Formats 1351
G.3 Characters and Glyphs 1352
G.4 Advantages and Disadvantages of Unicode 1353
G.5 Unicode Consortium’s Web Site 1353
G.6 Using Unicode 1355
G.7 Character Ranges 1357
H COM Integration (on CD) 1362
H.1 Introduction 1362
H.2 ActiveX Integration 1364
H.3 DLL Integration 1367
H.4 Internet and World Wide Web Resources 1371
I Introduction to HyperText Markup Language 4:
Part 1 (on CD) 1374
I.1 Introduction 1375
I.2 Markup Languages 1375
I.3 Editing HTML 1376
I.4 Common Elements 1376
I.5 Headers 1379
I.6 Linking 1380
I.7 Images 1382
I.8 Special Characters and More Line Breaks 1386
I.9 Unordered Lists 1388
I.10 Nested and Ordered Lists 1389
I.11 Internet and World Wide Web Resources 1392
J Introduction to HyperText Markup Language 4:
Part 2 (on CD) 1397
J.1 Introduction 1398
J.2 Basic HTML Tables 1398
J.3 Intermediate HTML Tables and Formatting 1400
J.4 Basic HTML Forms 1403
J.5 More Complex HTML Forms 1406
J.6 Internal Linking 1413
J.7 Creating and Using Image Maps 1416
J.8 Tags 1418
J.9 frameset Element 1420
J.10 Nested framesets 1422
J.11 Internet and World Wide Web Resources 1424
K Introduction to XHTML: Part 1 (on CD) 1430
K.1 Introduction 1431
K.2 Editing XHTML 1431
K.3 First XHTML Example 1432
K.4 W3C XHTML Validation Service 1435
K.5 Headers 1436
K.6 Linking 1438
K.7 Images 1441
K.8 Special Characters and More Line Breaks 1445
K.9 Unordered Lists 1447
K.10 Nested and Ordered Lists 1448
K.11 Internet and World Wide Web Resources 1451
L Introduction to XHTML: Part 2 (on CD) 1456
L.1 Introduction 1457
L.2 Basic XHTML Tables 1457
L.3 Intermediate XHTML Tables and Formatting 1460
L.4 Basic XHTML Forms 1462
L.5 More Complex XHTML Forms 1465
L.6 Internal Linking 1473
L.7 Creating and Using Image Maps 1476
L.8 meta Elements 1478
L.9 frameset Element 1479
L.10 Nested framesets 1483
L.11 Internet and World Wide Web Resources 1485
M HTML/XHTML Special Characters 1491
N HTML/XHTML Colors 1492
O Bit Manipulation (on CD) 1495
O.1 Introduction 1496
O.2 Bit Manipulation and the Bitwise Operators 1496
O.3 Class BitArray 1508
P Crystal Reports® for Visual Studio .NET 1513
P.1 Introduction 1513
P.2 Crystal Reports Web Site Resources 1513
P.3 Crystal Reports and Visual Studio .NET 1514
Bibliography 1518
Index 1522

Another C# Books
Another Programming Language Books
Download

Thursday, July 28, 2011

Introduction to Design Patterns in C#






1. What are Design Patterns? ............................................................ 21
Defining Design Patterns ...................................................................... 23
The Learning Process............................................................................ 25
Studying Design Patterns ...................................................................... 26
Notes on Object-Oriented Approaches ................................................. 26
C# Design Patterns................................................................................ 27
How This Book Is Organized ............................................................... 28
2. Syntax of the C# Language ............................................................ 29
Data Types ............................................................................................ 30
Converting Between Numbers and Strings ........................................... 32
Declaring Multiple Variables................................................................ 32
Numeric Constants ................................................................................ 32
Character Constants .............................................................................. 33
Variables ............................................................................................... 33
Declaring Variables as You Use Them............................................. 34
Multiple Equals Signs for Initialization................................................ 34
A Simple C# Program........................................................................... 34
Compiling & Running This Program................................................ 36
Arithmetic Operators............................................................................. 36
Increment and Decrement Operators .................................................... 37
Combining Arithmetic and Assignment Statements ............................. 37
Making Decisions in C#........................................................................ 38
Comparison Operators .......................................................................... 39
Combining Conditions .......................................................................... 39
The Most Common Mistake ................................................................. 40
The switch Statement ............................................................................ 41
C# Comments........................................................................................ 41
The Ornery Ternary Operator ............................................................... 42
Looping Statements in C#..................................................................... 42
The while Loop ..................................................................................... 42
The do-while Statement ........................................................................ 43
The for Loop ......................................................................................... 43
Declaring Variables as Needed in For Loops ....................................... 44
Commas in for Loop Statements........................................................... 44
How C# Differs From C ....................................................................... 45
Summary............................................................................................... 46
3. Writing Windows C# Programs ................................................... 47
Objects in C#......................................................................................... 47
Managed Languages and Garbage Collection ...................................... 48
Classes and Namespaces in C# ............................................................. 48
Building a C# Application .................................................................... 49
The Simplest Window Program in C# .................................................. 50
Windows Controls ................................................................................ 54
Labels ................................................................................................ 55
TextBox............................................................................................. 55
CheckBox.......................................................................................... 56
Buttons .............................................................................................. 56
Radio buttons .................................................................................... 56
Listboxes and Combo Boxes ............................................................ 57
The Items Collection......................................................................... 57
Menus................................................................................................ 58
ToolTips............................................................................................ 58
Other Windows Controls .................................................................. 59
The Windows Controls Program .......................................................... 59
Summary............................................................................................... 61
Programs on the CD-ROM ................................................................... 47
4. Using Classes and Objects in C# .................................................... 62
What Do We Use Classes For? ............................................................. 62
A Simple Temperature Conversion Program........................................ 62
Building a Temperature Class............................................................... 64
Converting to Kelvin......................................................................... 67
Putting the Decisions into the Temperature Class ................................ 67
Using Classes for Format and Value Conversion................................. 68
Handling Unreasonable Values......................................................... 71
A String Tokenizer Class ...................................................................... 71
Classes as Objects ................................................................................. 73
Class Containment ............................................................................ 75
Initialization.......................................................................................... 76
Classes and Properties........................................................................... 77
Programming Style in C#...................................................................... 79
Summary............................................................................................... 80
Programs on the CD-ROM ................................................................... 62
5. Inheritance ....................................................................................... 81
Constructors .......................................................................................... 81
Drawing and Graphics in C#................................................................. 82
Using Inheritance .................................................................................. 84
Namespaces........................................................................................... 85
Creating a Square From a Rectangle ................................................. 86
Public, Private and Protected ................................................................ 88
Overloading........................................................................................... 89
Virtual and Override Keywords ............................................................ 89
Overriding Methods in Derived Classes ............................................... 90
Replacing Methods Using New ............................................................ 91
Overriding Windows Controls .............................................................. 92
Interfaces ............................................................................................... 94
Abstract Classes .................................................................................... 95
Comparing Interfaces and Abstract Classes.......................................... 97
Summary............................................................................................... 99
Programs on the CD-ROM ................................................................... 99
6. UML Diagrams .............................................................................. 100
Inheritance........................................................................................... 102
Interfaces ............................................................................................. 103
Composition........................................................................................ 103
Annotation........................................................................................... 105
WithClass UML Diagrams ................................................................. 106
C# Project Files ................................................................................... 106
7. Arrays, Files and Exceptions in C# ............................................. 107
Arrays.................................................................................................. 107
Collection Objects............................................................................... 108
ArrayLists........................................................................................ 108
Hashtables ....................................................................................... 109
SortedLists ...................................................................................... 110
Exceptions ........................................................................................... 110
Multiple Exceptions ............................................................................ 112
Throwing Exceptions .......................................................................... 113
File Handling....................................................................................... 113
The File Object................................................................................ 113
Reading Text File........................................................................... 114
Writing a Text File .......................................................................... 114
Exceptions in File Handling................................................................ 114
Testing for End of File ........................................................................ 115
A csFile Class...................................................................................... 116
8. The Simple Factory Pattern......................................................... 121
How a Simple Factory Works ............................................................. 121
Sample Code ....................................................................................... 122
The Two Derived Classes ................................................................... 122
Building the Simple Factory............................................................... 123
Using the Factory............................................................................ 124
Factory Patterns in Math Computation............................................... 125
Programs on the CD-ROM ................................................................. 128
Thought Questions .............................................................................. 128
9. The Factory Method ..................................................................... 129
The Swimmer Class ............................................................................ 132
The Events Classes.............................................................................. 132
Straight Seeding .................................................................................. 133
Circle Seeding ................................................................................. 134
Our Seeding Program.......................................................................... 134
Other Factories .................................................................................... 135
When to Use a Factory Method .......................................................... 136
Thought Question................................................................................ 136
Programs on the CD-ROM ................................................................. 136
10. The Abstract Factory Pattern.................................................. 137
A GardenMaker Factory ..................................................................... 137
The PictureBox ............................................................................... 141
Handling the RadioButton and Button Events ................................ 142
Adding More Classes.......................................................................... 143
Consequences of Abstract Factory...................................................... 144
Thought Question................................................................................ 144
Programs on the CD-ROM ................................................................. 144
11. The Singleton Pattern ............................................................... 145
Creating Singleton Using a Static Method.......................................... 145
Exceptions and Instances .................................................................... 146
Throwing the Exception...................................................................... 147
Creating an Instance of the Class ........................................................ 147
Providing a Global Point of Access to a Singleton............................. 148
Other Consequences of the Singleton Pattern..................................... 149
Programs on Your CD-ROM.............................................................. 149
12. The Builder Pattern .................................................................. 150
An Investment Tracker........................................................................ 151
The Stock Factory........................................................................... 154
The CheckChoice Class .................................................................. 155
The ListboxChoice Class ................................................................ 156
Using the Items Collection in the ListBox Control ............................ 157
Plotting the Data.............................................................................. 158
The Final Choice ............................................................................. 159
Consequences of the Builder Pattern.................................................. 160
Thought Questions .............................................................................. 161
Programs on the CD-ROM ................................................................. 161
13. The Prototype Pattern .............................................................. 162
Cloning in C# ...................................................................................... 163
Using the Prototype............................................................................. 163
Cloning the Class ................................................................................ 167
Using the Prototype Pattern ................................................................ 170
Dissimilar Classes with the Same Interface .................................... 172
Prototype Managers ............................................................................ 176
Consequences of the Prototype Pattern............................................... 176
Thought Question................................................................................ 177
Programs on the CD-ROM ................................................................. 177
Summary of Creational Patterns ......................................................... 178
14. The Adapter Pattern................................................................. 180
Moving Data Between Lists................................................................ 180
Making an Adapter.............................................................................. 182
Using the DataGrid ............................................................................. 183
Detecting Row Selection................................................................. 186
Using a TreeView ............................................................................... 186
The Class Adapter ............................................................................... 188
Two-Way Adapters............................................................................. 190
Object Versus Class Adapters in C# ................................................... 190
Pluggable Adapters ............................................................................. 191
Thought Question................................................................................ 191
Programs on the CD-ROM ................................................................. 191
15. The Bridge Pattern.................................................................... 192
The VisList Classes............................................................................. 195
The Class Diagram.............................................................................. 196
Extending the Bridge .......................................................................... 197
Windows Forms as Bridges ................................................................ 201
Consequences of the Bridge Pattern ................................................... 202
Thought Question................................................................................ 203
Programs on the CD-ROM ................................................................. 203
16. The Composite Pattern............................................................. 204
An Implementation of a Composite .................................................... 205
Computing Salaries............................................................................. 206
The Employee Classes ........................................................................ 206
The Boss Class.................................................................................... 209
Building the Employee Tree ............................................................... 210
Self-Promotion.................................................................................... 213
Doubly Linked Lists ........................................................................... 213
Consequences of the Composite Pattern............................................. 215
A Simple Composite ........................................................................... 215
Composites in .NET............................................................................ 216
Other Implementation Issues .............................................................. 216
Thought Questions .............................................................................. 216
Programs on the CD-ROM ................................................................. 217
17. The Decorator Pattern.............................................................. 218
Decorating a CoolButton .................................................................... 218
Handling events in a Decorator........................................................... 220
Layout Considerations .................................................................... 221
Control Size and Position................................................................ 221
Multiple Decorators ............................................................................ 222
Nonvisual Decorators.......................................................................... 225
Decorators, Adapters, and Composites ............................................... 226
Consequences of the Decorator Pattern.............................................. 226
Thought Questions .............................................................................. 226
Programs on the CD-ROM ................................................................. 227
18. The Façade Pattern................................................................... 228
What Is a Database? ............................................................................ 228
Getting Data Out of Databases............................................................ 230
Kinds of Databases.............................................................................. 231
ODBC.................................................................................................. 232
Database Structure .............................................................................. 232
Using ADO.NET................................................................................. 233
Connecting to a Database................................................................ 233
Reading Data from a Database Table ............................................. 234
dtable = dset.Tables [0]; ............................................................ 235
Executing a Query........................................................................... 235
Deleting the Contents of a Table ..................................................... 235
Adding Rows to Database Tables Using ADO.NET .......................... 236
Building the Façade Classes ............................................................... 237
Building the Price Query................................................................. 239
Making the ADO.NET Façade............................................................ 239
The DBTable class.......................................................................... 242
Creating Classes for Each Table ......................................................... 244
Building the Price Table ..................................................................... 246
Loading the Database Tables .............................................................. 249
The Final Application ......................................................................... 251
What Constitutes the Façade? ............................................................. 252
Consequences of the Façade ............................................................... 253
Thought Question................................................................................ 253
Programs on the CD-ROM ................................................................. 253
19. The Flyweight Pattern .............................................................. 254
Discussion........................................................................................... 255
Example Code ..................................................................................... 256
The Class Diagram.......................................................................... 261
Selecting a Folder............................................................................ 261
Handling the Mouse and Paint Events ................................................ 263
Flyweight Uses in C#.......................................................................... 264
Sharable Objects ................................................................................. 265
Copy-on-Write Objects....................................................................... 265
Thought Question................................................................................ 266
Programs on the CD-ROM ................................................................. 266
20. The Proxy Pattern..................................................................... 267
Sample Code ....................................................................................... 268
Proxies in C# ....................................................................................... 270
Copy-on-Write .................................................................................... 271
Comparison with Related Patterns ...................................................... 271
Thought Question................................................................................ 271
Programs on the CD-ROM ................................................................. 271
21. Chain of Responsibility............................................................. 274
Applicability........................................................................................ 275
Sample Code ....................................................................................... 276
The List Boxes .................................................................................... 280
Programming a Help System .............................................................. 282
Receiving the Help Command ........................................................ 286
A Chain or a Tree? .............................................................................. 287
Kinds of Requests ............................................................................... 289
Examples in C# ................................................................................... 289
Consequences of the Chain of Responsibility .................................... 290
Thought Question................................................................................ 290
Programs on the CD-ROM ................................................................. 291
22. The Command Pattern ............................................................. 292
Motivation........................................................................................... 292
Command Objects............................................................................... 293
Building Command Objects................................................................ 294
Consequences of the Command Pattern ............................................. 297
The CommandHolder Interface .......................................................... 297
Providing Undo ................................................................................... 301
Thought Questions .............................................................................. 309
Programs on the CD-ROM ................................................................. 310
23. The Interpreter Pattern............................................................ 311
Motivation........................................................................................... 311
Applicability........................................................................................ 311
A Simple Report Example .................................................................. 312
Interpreting the Language ................................................................... 314
Objects Used in Parsing ...................................................................... 315
Reducing the Parsed Stack .................................................................. 319
Implementing the Interpreter Pattern.................................................. 321
The Syntax Tree .............................................................................. 322
Consequences of the Interpreter Pattern ............................................. 326
Thought Question................................................................................ 327
Programs on the CD-ROM ................................................................. 327
24. The Iterator Pattern.................................................................. 328
Motivation........................................................................................... 328
Sample Iterator Code .......................................................................... 329
Fetching an Iterator ......................................................................... 330
Filtered Iterators .................................................................................. 331
The Filtered Iterator ........................................................................ 331
Keeping Track of the Clubs ................................................................ 334
Consequences of the Iterator Pattern .................................................. 335
Programs on the CD-ROM ................................................................. 336
25. The Mediator Pattern ............................................................... 337
An Example System............................................................................ 337
Interactions Between Controls ............................................................ 339
Sample Code ....................................................................................... 341
Initialization of the System ............................................................. 345
Mediators and Command Objects....................................................... 345
Consequences of the Mediator Pattern................................................ 347
Single Interface Mediators.................................................................. 348
Implementation Issues......................................................................... 349
Programs on the CD-ROM ................................................................. 349
26. The Memento Pattern............................................................... 350
Motivation........................................................................................... 350
Implementation ................................................................................... 351
Sample Code ....................................................................................... 351
A Cautionary Note .......................................................................... 358
Command Objects in the User Interface ............................................. 358
Handling Mouse and Paint Events ...................................................... 360
Consequences of the Memento ........................................................... 361
Thought Question................................................................................ 361
Programs on the CD-ROM ................................................................. 362
27. The Observer Pattern ............................................................... 363
Watching Colors Change .................................................................... 364
The Message to the Media .................................................................. 367
Consequences of the Observer Pattern................................................ 368
Programs on the CD-ROM ................................................................. 369
28. The State Pattern ...................................................................... 370
Sample Code ....................................................................................... 370
Switching Between States ................................................................... 376
How the Mediator Interacts with the State Manager .......................... 377
The ComdToolBarButton ............................................................... 378
Handling the Fill State ........................................................................ 381
Handling the Undo List....................................................................... 382
The VisRectangle and VisCircle Classes............................................ 385
Mediators and the God Class .............................................................. 387
Consequences of the State Pattern...................................................... 388
State Transitions .................................................................................. 388
Thought Questions .............................................................................. 389
Programs on the CD-ROM ................................................................. 389
29. The Strategy Pattern................................................................. 390
Motivation........................................................................................... 390
Sample Code ....................................................................................... 391
The Context......................................................................................... 392
The Program Commands .................................................................... 393
The Line and Bar Graph Strategies..................................................... 394
Drawing Plots in C#............................................................................ 394
Making Bar Plots ............................................................................ 395
Making Line Plots ........................................................................... 396
Consequences of the Strategy Pattern................................................. 398
Programs on the CD-ROM ................................................................. 398
30. The Template Method Pattern ................................................ 399
Motivation........................................................................................... 399
Kinds of Methods in a Template Class ............................................... 401
Sample Code ....................................................................................... 402
Drawing a Standard Triangle .......................................................... 404
Drawing an Isosceles Triangle ........................................................ 404
The Triangle Drawing Program.......................................................... 405
Templates and Callbacks .................................................................... 406
Summary and Consequences .............................................................. 407
Programs on the CD-ROM ................................................................. 408
31. The Visitor Pattern ................................................................... 409
Motivation........................................................................................... 409
When to Use the Visitor Pattern ......................................................... 411
Sample Code ....................................................................................... 411
Visiting the Classes ............................................................................. 413
Visiting Several Classes...................................................................... 414
Bosses Are Employees, Too ............................................................... 416
Catch-All Operations with Visitors .................................................... 417
Double Dispatching............................................................................. 419
Why Are We Doing This? .................................................................. 419
Traversing a Series of Classes ............................................................ 419
Consequences of the Visitor Pattern................................................... 420
Thought Question................................................................................ 420
Programs on the CD-ROM ................................................................. 421
32. Bibliography .............................................................................. 422


Another C# Books
Another Programming Language Books
Another Software Engineering Books
Download

Saturday, July 16, 2011

Introduction to C# Programming for the Microsoft .NET Platform






Contents

Introduction
Course Materials..........................................................................................2
Prerequisites................................................................................................3
Course Outline ............................................................................................4
Course Outline (continued) ...........................................................................5
Course Outline (continued) ...........................................................................6
Microsoft Certified Professional Program .......................................................7
Facilities..................................................................................................... 9
Module 1: Overview of the Microsoft .NET Platform
Overview.................................................................................................... 1
Introduction to the .NET Platform.................................................................. 2
Overview of the .NET Framework ................................................................. 4
Benefits of the .NET Framework ................................................................... 5
The .NET Framework Components ................................................................7
Languages in the .NET Framework.............................................................. 13
Review ..................................................................................................... 14
Module 2: Overview of C#
Overview.................................................................................................... 1
Structure of a C# Program............................................................................. 2
Basic Input/Output Operations.......................................................................9
Recommended Practices ............................................................................. 15
Compiling, Running, and Debugging............................................................ 22
Lab 2: Creating a Simple C# Program........................................................... 36
Review ..................................................................................................... 45
Module 3: Using Value-Type Variables
Overview.................................................................................................... 1
Common Type System .................................................................................2
Naming Variables ........................................................................................9
Using Built-in Data Types........................................................................... 15
Compound Assignment .............................................................................. 18
Increment and Decrement........................................................................... 20
Creating User-Defined Data Types............................................................... 24
Converting Data Types ............................................................................... 28
Lab 3: Creating and Using Types ................................................................. 32
Review ..................................................................................................... 36
Module 4: Statements and Exceptions
Overview.................................................................................................... 1
Introduction to Statements............................................................................ 2
Using Selection Statements ...........................................................................6
Using Iteration Statements .......................................................................... 17
Using Jump Statements............................................................................... 29
Lab 4.1: Using Statements .......................................................................... 32
Handling Basic Exceptions ......................................................................... 41
Raising Exceptions .................................................................................... 51
Lab 4.2: Using Exceptions .......................................................................... 62
Review ..................................................................................................... 72
Module 5: Methods and Parameters
Overview.................................................................................................... 1
Using Methods ............................................................................................2
Using Parameters....................................................................................... 16
Using Overloaded Methods ......................................................................... 30
Lab 5: Creating and Using Methods ............................................................. 38
Review ..................................................................................................... 50
Module 6: Arrays
Overview.................................................................................................... 1
Overview of Arrays......................................................................................2
Creating Arrays ......................................................................................... 11
Using Arrays ............................................................................................. 18
Lab 6: Creating and Using Arrays ................................................................ 31
Review ..................................................................................................... 42
Module 7: Essentials of Object-Oriented Programming
Overview.................................................................................................... 1
Classes and Objects......................................................................................2
Using Encapsulation................................................................................... 10
C# and Object Orientation........................................................................... 21
Lab 7: Creating and Using Classes ............................................................... 39
Defining Object-Oriented Systems............................................................... 53
Review ..................................................................................................... 62
Module 8: Using Reference-Type Variables
Overview.................................................................................................... 1
Using Reference-Type Variables.................................................................... 2
Using Common Reference Types ................................................................. 15
The Object Hierarchy ................................................................................. 23
Namespaces in the .NET Framework............................................................ 29
Lab 8.1: Defining And Using Reference-Type Variables ................................. 35
Data Conversions....................................................................................... 43
Multimedia: Type-Safe Casting ................................................................... 56
Lab 8.2 Converting Data............................................................................. 57
Review ..................................................................................................... 63
Module 9: Creating and Destroying Objects
Overview.................................................................................................... 1
Using Constructors ......................................................................................2
Initializing Data ......................................................................................... 13
Lab 9.1: Creating Objects ........................................................................... 31
Objects and Memory.................................................................................. 39
Using Destructors...................................................................................... 45
Lab 9.2: Destroying Objects........................................................................ 60
Review ..................................................................................................... 65
Module 10: Inheritance in C#
Overview.................................................................................................... 1
Deriving Classes..........................................................................................2
Implementing Methods ............................................................................... 10
Using Sealed Classes.................................................................................. 26
Using Interfaces......................................................................................... 28
Using Abstract Classes ............................................................................... 42
Lab 10: Using Inheritance to Implement an Interface...................................... 53
Review ..................................................................................................... 71
Module 11: Aggregation, Namespaces, and Advanced Scope
Overview.................................................................................................... 1
Using Internal Classes, Methods, and Data......................................................2
Using Aggregation ..................................................................................... 11
Lab 11.1: Specifying Internal Access............................................................ 22
Using Namespaces ..................................................................................... 28
Using Modules and Assemblies ................................................................... 49
Lab 11.2: Using Namespaces and Assemblies................................................ 63
Review ..................................................................................................... 69
Module 12: Operators, Delegates, and Events
Overview.................................................................................................... 1
Introduction to Operators ..............................................................................2
Operator Overloading ...................................................................................8
Lab 12.1: Defining Operators ...................................................................... 21
Creating and Using Delegates ...................................................................... 40
Defining and Using Events.......................................................................... 50
Demonstration: Handling Events.................................................................. 56
Lab 12.2: Defining and Using Events ........................................................... 57
Module 13: Properties and Indexers
Overview.................................................................................................... 1
Using Properties ..........................................................................................2
Using Indexers .......................................................................................... 17
Lab 13: Using Properties and Indexers.......................................................... 33
Review ..................................................................................................... 42
Module 14: Attributes
Overview.................................................................................................... 1
Overview of Attributes .................................................................................2
Defining Custom Attributes ......................................................................... 13
Retrieving Attribute Values ......................................................................... 22
Lab 14: Defining and Using Attributes ......................................................... 26
Review ..................................................................................................... 34
Appendix A: Resources for Further Study
Resources for C# .........................................................................................1

Another C# Books
Another .NET Book
Another Programming Language Books
Download

Tuesday, February 22, 2011

Thinking in C#






Overview
Introduction 3
1: Those Who Can, Code 15
2: Introduction to Objects 15
3: Hello, Objects 51
4: Controlling Program Flow 89
5: Initialization & Cleanup 151
6: Coupling and Cohesion 215
6a: Hiding the Implementation 234
7: Reusing classes 250
8: Interfaces and Implementation 295
8a: Interfaces 333
9: Collecting Your Objects 391
10: Error Handling With Exceptions 481
11: I/O in C# 519
12: Reflection and Attributes 557
13: Programming Windows Forms 587
14: GDI+ Overview 705
14: Multithreaded Programming 721
15: XML 759
16: Web Services 761
A: C# For Java Programmers 763
B: C# For Visual Basic Programmers 765
C: C# Programming Guidelines 767
D: Resources 779
Index 779


Another C# Books
Download

Wednesday, January 12, 2011

Visual C# .NET Programming





Harold Davis

The Structure of This Book: About the Musical Part Names

Since C# is a programming language named after a musical note, I thought it appropriate to involve musical concepts when structuring this book. In keeping with this, I've named each of the four parts of the book after movements in a classical composition. These movements prelude, allemande, courante, and gigue-primarily are found in Baroque music. Musical scholars should note that I have not been compulsive about the accuracy or consistency of the musical metaphor. The point really is the metaphor and how it relates to the structure of this book and to programming in C#.

The structure of the book is essentially spiral, like a chambered nautilus shell or the pattern in this volume's cover photograph of a Zen garden. By the end of the book, readers will be able to comprehend and accomplish things that seemed shadowy and mysterious when they plunged in at the beginning. Each of the four parts represents a different stage in this quest for skills and understanding.

Part 1: Prelude-Service with a Smile
In classical music, the prelude introduces the work. Often composed in a free-flowing style, it sets the mood and mode for the rest of the work and is designed to pique the interest of the audience. It can contain references to ideas that are delivered later-foreshadowings, a taste of things to come. The themes in the prelude are not whole ideas but snippets, motifs-just enough to whet the appetite and make the listener want more. These motifs are pre-echoesnot déjà vu, which are vague memories of things already seen, but rather premonitions of things to come. If you listen to the composition more than once, then in the prelude you should be able to begin to hear the pattern of the entire piece.

At the same time that a prelude introduces the larger work; it is an organic unit in and of itself, with a beginning, middle, and end. This cohesive mini-composition exists within the larger whole and has its own sense of narrative conflict and resolution, point and counterpoint, all reconciling in a conclusion that serves as an introduction.

Our prelude introduces the theme of the web service. Web services have been hailed by some as revolutionary: a brand new kind of unit of executable code, fit for the distributed environments of the Internet age.

A web service is not an end in and of itself. To actually do anything as a part of a program, it must be used-or, put another way, 'consumed.'

It is also the case that this book is not 'about' web services; it is about programming in the C# language and the .NET Framework.

Our prelude explores creating a web service, in Chapter 1, 'Creating a Web Service,' and coding ASP.NET web applications to consume the web service, in Chapter 2, 'Consuming the Service on the Web,' as a dramatic way to jump into the topics that will form the pattern of the composition that is this book. Keep your eyes and ears open for premonitions that reveal this book's real themes: the best way to write C# code for clarity, and patterns and practice of communication between objects.

Part II: Allemande-Striding Forward

The allemande is a movement of great substance that directly follows the prelude of a musical suite and picks up where the prelude leaves off. It is stately in manner and can be highly stylized. The allemande carries forward the mood prefigured in the prelude and introduces gravity into the suite; but the prelude's free style gives way to the processional-like regularity of the allemande.

The sentiments casually introduced in the prelude have become a stepping dance with reality and the allemande keeps it all moving. The meter is steady and so is the progress. The allemande is striding forward without hesitation into the future, and the future is now.

Early allemandes come in three sections, or strains, that are related but not the same. The second strain contrasts with the first strain. They resolve in the third and final section, which paves the way for the next movement in the composition.

You can't have an application without a user interface. Chapter 3, 'Windows Uses Web
Services, Too!,' is an introduction to programming the Windows user interface-while carrying
on the web services motif explicitly introduced in the first part of the book. The allemande
also keeps one of the underlying themes of this book moving, with an explanation of the
asynchronous communication design pattern.

Chapter 4, 'Building a Better Windows Interface,' is about the hard-core plumbing of a
Windows interface. Services have been left behind. This is the territory of displaying lists of
items, menus, common dialogs, and such. This strain of the allemande may be concerned with
conventional Windows development, and it may be a little dissonant, but it has a sense of
humor. For example, you'll start this chapter by making round buttons dance.

The allemande is complete with Chapter 5, 'Reflecting on Classes.' We've taken strides
forward and are now past Windows, in the realm of objects and classes. This chapter fits C#
code in with the .NET Framework. Once again, it's about communication. Classes are not
islands, and they must be instantiated to be used. It is a time for reflection, for understanding
of ourselves and our environment, and also to soar the peaks of what is possible-knowing that
soon we must return to the humble arenas of language and syntax that make it all possible.

Part III: Courante-The Dance of the Language

The courante is a dance movement of vigor and complexity. It is rhythmically interesting and exciting, but capable of hard work. A courante combines playfulness and movement with heart, soul, and substance.

Courantes were used for dancing in court and in theater, and later as stylized movements in instrumental music. The form combines rhythmic and metrical fluidity with a complicated texture.

This part, the courante, is in many ways the heart and soul of this book.
We start with Chapter 6, 'Zen and Now: The C# Language.' What could be more iportant
than a good understanding and grasp of syntax of the beautiful C# language?

Moving on, Chapter 7, 'Arrays, Indexers, and Collections,' shows you how to work with
groups of objects-and make them dance. Chapter 8, 'The Life of the Object in C#,' is all about classes and object-oriented programming. Since all programming in C# is class-based and object-oriented-the only question is whether the programming is good object-oriented code or bad object-oriented code-the material in that chapter is iportant. I think the running example in

Chapter 8 is quite a bit of fun. This program is a simulation based on the ideas of Pulitzer Prize-winning author Jared Diamond. As you'll see, the program allows users to track the rise (and fall) of tribes and civilizations.

Strings are everything, and everything is string. If you know how to manipulate strings, you know lots of things-and you'll find out how in Chapter 9, 'Everything Is String Manipulation.'

Our courante has proceeded from language and syntax, and onward through arrays,
collections, objects, and classes. Coming back to the beginning, it has explained the sophisticated manipulation of language elements. This is a complex dance, a spiral within a spiral. As the courante winds down, we're ready to move onward-by looking outwards instead of inwards.

Part IV: Gigue-Leaping to Success

The gigue-which became a popular Baroque movement-probably originated in Great Britain as the 'jig' or 'jigg' (although note that the Old French verb giguer means 'to leap' or 'to gambol'). Whatever the derivation of the word, it's clear that in Elizabethan times a jig was a dance-notably performed by Scottish lairds-that involved a great deal of jumping (or, as one contemporary put it, the dance is 'full of leapings').

In the context of our gigue, this remains true: the movement is full of leapings. It is happy, exuberant, full of life, and extroverted.

It's time to turn the knowledge we've learned in the early movements outwards-and use the gigue to interact with the world.

Chapter 10, 'Working with Streams and Files,' shows you how to work with files-and,
generally, how to serialize objects.

Chapter 11, 'Messaging,' explains how to program messaging applications. Using message queues, as you'll see in Chapter 11, it's possible to build families of applications that divide workloads and start and stop each other.

Chapter 12, 'Working with XML and ADO.NET,' covers interacting with XML and databases.

Chapter 13, 'Web Services as Architecture,' wraps it all up. Coming back to the beginning after all, Chapter 1 started with a web service-we can use the sophisticated tools and techniques that we've learned in order to build web services that are truly exciting! The chapter concludes with an example showing how to use the TerraServer web service and display aerial photos or topographic maps of almost anywhere in the U.S. at a variety of magnifications.

And, finally, the gigue is up! Now programming in C# is up to you…


Another C# Book
Another .NET Books
Another Programming Language Books
Download
Related Posts with Thumbnails

Put Your Ads Here!