Preface |
|
xi | |
|
Chapter 1 Introduction to Computers and Programming |
|
|
1 | (52) |
|
|
1 | (1) |
|
1.2 Hardware and Software |
|
|
2 | (5) |
|
1.3 How Computers Store Data |
|
|
7 | (4) |
|
|
11 | (7) |
|
1.5 Graphical User Interfaces |
|
|
18 | (3) |
|
|
21 | (2) |
|
1.7 The Program Development Process |
|
|
23 | (4) |
|
1.8 Getting Started with the Visual Studio Environment |
|
|
27 | (26) |
|
Tutorial 1-1 Starting Visual Studio and Setting Up the Environment |
|
|
28 | (3) |
|
Tutorial 1-2 Starting a New Visual C# Project |
|
|
31 | (2) |
|
Tutorial 1-3 Saving and Closing a Project |
|
|
33 | (9) |
|
Tutorial 1-4 Opening an Existing Project |
|
|
42 | (2) |
|
Tutorial 1-5 Getting Familiar with the Visual Studio Environment |
|
|
44 | (1) |
|
|
45 | (1) |
|
|
46 | (5) |
|
|
51 | (2) |
|
Chapter 2 Introduction to Visual C# |
|
|
53 | (64) |
|
2.1 Getting Started with Forms and Controls |
|
|
53 | (9) |
|
2.2 Creating the GUI for Your First Visual C# Application: The Hello World Application |
|
|
62 | (5) |
|
Tutorial 2-1 Creating the GUI for the Hello World Application |
|
|
63 | (4) |
|
2.3 Introduction to C# Code |
|
|
67 | (10) |
|
2.4 Writing Code for the Hello World Application |
|
|
77 | (2) |
|
Tutorial 2-2 Writing Code for the Hello World Application |
|
|
77 | (2) |
|
|
79 | (12) |
|
Tutorial 2-3 Creating the Language Translator Application |
|
|
88 | (3) |
|
2.6 Making Sense of IntelliSense |
|
|
91 | (1) |
|
|
92 | (11) |
|
Tutorial 2-4 Creating the Flags Application |
|
|
96 | (4) |
|
Tutorial 2-5 Creating the Card Flip Application |
|
|
100 | (3) |
|
2.8 Comments, Blank Lines, and Indentation |
|
|
103 | (3) |
|
2.9 Writing the Code to Close an Application's Form |
|
|
106 | (1) |
|
2.10 Dealing with Syntax Errors |
|
|
106 | (11) |
|
|
108 | (1) |
|
|
108 | (5) |
|
|
113 | (4) |
|
Chapter 3 Processing Data |
|
|
117 | (78) |
|
3.1 Reading Input with TextBox Controls |
|
|
117 | (2) |
|
3.2 A First Look at Variables |
|
|
119 | (12) |
|
Tutorial 3.1 The Birth Date String Application |
|
|
126 | (5) |
|
3.3 Numeric Data Types and Variables |
|
|
131 | (5) |
|
3.4 Performing Calculations |
|
|
136 | (5) |
|
3.5 Inputting and Outputting Numeric Values |
|
|
141 | (8) |
|
Tutorial 3-2 Calculating Fuel Economy |
|
|
146 | (3) |
|
3.6 Formatting Numbers with the ToString Method |
|
|
149 | (7) |
|
Tutorial 3-3 Creating the Sale Price Calculator Application with Currency Formatting |
|
|
152 | (4) |
|
3.7 Simple Exception Handling |
|
|
156 | (8) |
|
Tutorial 3-4 Creating the Test Average Application with Exception Handling |
|
|
160 | (4) |
|
3.8 Using Named Constants |
|
|
164 | (1) |
|
3.9 Declaring Variables as Fields |
|
|
165 | (8) |
|
Tutorial 3-5 Creating the Change Counter Application |
|
|
169 | (4) |
|
3.10 Using the Math Class |
|
|
173 | (2) |
|
|
175 | (20) |
|
|
185 | (1) |
|
|
185 | (5) |
|
|
190 | (5) |
|
Chapter 4 Making Decisions |
|
|
195 | (70) |
|
4.1 Decision Structures and the if Statement |
|
|
195 | (9) |
|
Tutorial 4-1 Completing the Test Score Average Application |
|
|
200 | (4) |
|
4.2 The if-else Statement |
|
|
204 | (6) |
|
Tutorial 4-2 Completing the Payroll with Overtime Application |
|
|
206 | (4) |
|
4.3 Nested Decision Structures |
|
|
210 | (11) |
|
Tutorial 4-3 Completing the Loan Qualifier Application |
|
|
212 | (9) |
|
|
221 | (5) |
|
4.5 Bool Variables and Flags |
|
|
226 | (1) |
|
|
226 | (4) |
|
4.7 Preventing Data Conversion Exceptions with the TryParse Methods |
|
|
230 | (8) |
|
Tutorial 4-4 Calculating Fuel Economy |
|
|
235 | (3) |
|
|
238 | (1) |
|
4.9 Radio Buttons and Check Boxes |
|
|
239 | (7) |
|
Tutorial 4-5 Creating the Color Theme Application |
|
|
244 | (2) |
|
4.10 The switch Statement |
|
|
246 | (3) |
|
4.11 Introduction to List Boxes |
|
|
249 | (16) |
|
Tutorial 4-6 Creating the Time Zone Application |
|
|
251 | (4) |
|
|
255 | (1) |
|
|
255 | (4) |
|
|
259 | (6) |
|
Chapter 5 Loops, Files, and Random Numbers |
|
|
265 | (72) |
|
|
265 | (2) |
|
|
267 | (11) |
|
Tutorial 5-1 Using a Loop to Calculate an Account Balance |
|
|
271 | (3) |
|
Tutorial 5-2 Enhancing the Ending Balance Application |
|
|
274 | (4) |
|
5.3 The++and -- operators |
|
|
278 | (1) |
|
|
279 | (8) |
|
Tutorial 5-3 Using the for Loop |
|
|
284 | (3) |
|
|
287 | (2) |
|
5.6 Using Files for Data Storage |
|
|
289 | (26) |
|
Tutorial 5-4 Writing Data to a Text File |
|
|
295 | (5) |
|
Tutorial 5-5 Appending Data to the Friend.txt File |
|
|
300 | (8) |
|
Tutorial 5-6 Using a Loop to Read to the End of a File |
|
|
308 | (4) |
|
Tutorial 5-7 Calculating a Running Total |
|
|
312 | (3) |
|
5.7 The OpenFileDialog and SaveFileDialog Controls |
|
|
315 | (6) |
|
|
321 | (5) |
|
Tutorial 5-8 Simulating Coin Tosses |
|
|
323 | (3) |
|
|
326 | (11) |
|
Tutorial 5-9 Creating a Load Event Handler |
|
|
327 | (3) |
|
|
330 | (1) |
|
|
330 | (3) |
|
|
333 | (4) |
|
Chapter 6 Modularizing Your Code with Methods |
|
|
337 | (50) |
|
6.1 Introduction to Methods |
|
|
337 | (2) |
|
|
339 | (8) |
|
Tutorial 6-1 Creating and Calling Methods |
|
|
343 | (4) |
|
6.3 Passing Arguments to Methods |
|
|
347 | (11) |
|
Tutorial 6-2 Passing an Argument to a Method |
|
|
350 | (8) |
|
6.4 Passing Arguments by Reference |
|
|
358 | (7) |
|
Tutorial 6-3 Using an Output Parameter |
|
|
361 | (4) |
|
6.5 Value-Returning Methods |
|
|
365 | (22) |
|
Tutorial 6-4 Writing a Value-Returning Method |
|
|
370 | (3) |
|
Tutorial 6-5 Modularizing Input Validation with a Boolean Method |
|
|
373 | (6) |
|
|
379 | (1) |
|
|
379 | (3) |
|
|
382 | (5) |
|
Chapter 7 Arrays and Lists |
|
|
387 | (76) |
|
7.1 Value Types and Reference Types |
|
|
387 | (3) |
|
|
390 | (12) |
|
Tutorial 7-1 Using an Array to Hold a List of Random Lottery Numbers |
|
|
397 | (5) |
|
7.3 Working with Files and Arrays |
|
|
402 | (3) |
|
7.4 Passing Arrays as Arguments to Methods |
|
|
405 | (7) |
|
7.5 Some Useful Array Algorithms |
|
|
412 | (15) |
|
Tutorial 7-2 Processing an Array |
|
|
422 | (5) |
|
7.6 Advanced Algorithms for Sorting and Searching Arrays |
|
|
427 | (7) |
|
7.7 Two-Dimensional Arrays |
|
|
434 | (9) |
|
Tutorial 7-3 Completing the Seating Chart Application |
|
|
437 | (6) |
|
|
443 | (1) |
|
|
444 | (19) |
|
Tutorial 7-4 Completing the Test Score List Application |
|
|
450 | (6) |
|
|
456 | (1) |
|
Review Questions and Exercises |
|
|
456 | (3) |
|
|
459 | (4) |
|
Chapter 8 More about Processing Data |
|
|
463 | (72) |
|
|
463 | (1) |
|
8.2 String and Character Processing |
|
|
463 | (35) |
|
Tutorial 8-1 Completing the Password Validation Application |
|
|
469 | (13) |
|
Tutorial 8-2 Completing the Telephone Format Application |
|
|
482 | (4) |
|
Tutorial 8-3 Completing the Telephone Unformat Application |
|
|
486 | (7) |
|
Tutorial 8-4 Completing the CSV Reader Application |
|
|
493 | (5) |
|
|
498 | (15) |
|
Tutorial 8-5 Completing the Phonebook Application |
|
|
507 | (6) |
|
|
513 | (7) |
|
Tutorial 8-6 Completing the Color Spectrum Application |
|
|
516 | (4) |
|
8.5 The ImageList Control |
|
|
520 | (15) |
|
Tutorial 8-7 Completing the Random Card Application |
|
|
523 | (3) |
|
|
526 | (1) |
|
|
526 | (4) |
|
|
530 | (5) |
|
Chapter 9 Classes and Multiform Projects |
|
|
535 | (64) |
|
9.1 Introduction to Classes |
|
|
535 | (12) |
|
Tutorial 9-1 Creating and Using the Coin Class |
|
|
542 | (5) |
|
|
547 | (8) |
|
Tutorial 9-2 Creating and Using the CellPhone Class |
|
|
550 | (5) |
|
9.3 Parameterized Constructors and Overloading |
|
|
555 | (7) |
|
Tutorial 9-3 Creating and Using the BankAccount Class |
|
|
556 | (6) |
|
9.4 Storing Class Type Objects in Arrays and Lists |
|
|
562 | (6) |
|
Tutorial 9-4 Completing the Cell Phone Inventory Application |
|
|
564 | (4) |
|
9.5 Finding the Classes and Their Responsibilities in a Problem |
|
|
568 | (8) |
|
9.6 Creating Multiple Forms in a Project |
|
|
576 | (23) |
|
Tutorial 9-5 Creating an Application with Two Forms |
|
|
581 | (4) |
|
Tutorial 9-6 Accessing a Control on a Different Form |
|
|
585 | (6) |
|
|
591 | (1) |
|
|
591 | (4) |
|
|
595 | (4) |
|
Chapter 10 Inheritance and Polymorphism |
|
|
599 | (40) |
|
|
599 | (18) |
|
Tutorial 10-1 Creating and Testing the SavingsAccount and CDAccount Classes |
|
|
609 | (8) |
|
|
617 | (10) |
|
Tutorial 10-2 Completing the Polymorphism Application |
|
|
622 | (5) |
|
|
627 | (12) |
|
Tutorial 10-3 Completing the Computer Science Student Application |
|
|
629 | (5) |
|
|
634 | (1) |
|
|
634 | (3) |
|
|
637 | (2) |
|
|
639 | (74) |
|
11.1 Introduction to Database Management Systems |
|
|
639 | (2) |
|
11.2 Tables, Rows, and Columns |
|
|
641 | (3) |
|
11.3 Creating a Database in Visual Studio |
|
|
644 | (8) |
|
Tutorial 11-1 Starting the Phone Book Application and Creating the Phonelist.mdf Database |
|
|
645 | (7) |
|
11.4 The DataGridView Control |
|
|
652 | (8) |
|
Tutorial 11-2 Completing the Phone Book Application |
|
|
653 | (7) |
|
11.5 Connecting to an Existing Database and Using Details View Controls |
|
|
660 | (10) |
|
Tutorial 11-3 Creating the Products Application and Using a Details View |
|
|
661 | (9) |
|
11.6 More About Data-Bound Controls |
|
|
670 | (12) |
|
Tutorial 11-4 Creating the Product Lookup Application |
|
|
674 | (2) |
|
Tutorial 11-5 Creating the Multiform Products Application |
|
|
676 | (6) |
|
11.7 Selecting Data with the SQL Select Statement |
|
|
682 | (31) |
|
Tutorial 11-6 Creating the Product Queries Application |
|
|
688 | (9) |
|
Tutorial 11-7 Creating the Product Queries Application |
|
|
697 | (5) |
|
Tutorial 11-8 Creating the Product Search Application |
|
|
702 | (5) |
|
|
707 | (1) |
|
|
707 | (4) |
|
|
711 | (2) |
Appendix A C# Primitive Data Types |
|
713 | (2) |
Appendix B Additional User Interface Controls |
|
715 | (20) |
Appendix C ASCII/Unicode Characters |
|
735 | (2) |
Appendix D Answers to Checkpoint Questions |
|
737 | (20) |
Index |
|
757 | |