Home Blog Index Search Articles Books Contact Me About Rod
Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer

Overview Table of Contents Source Code
Updates Info at Wrox.com Wrox Forum
Barnes & Noble
 

Section I: The Visual Studio IDE and Controls

The lessons in this section explain how to use the Visual Studio integrated development environment (IDE) and how to use the controls that make up a user interface. These form the foundation on which you build everything else in a Visual C# program.

Lesson 1, "Getting Started with the Visual Studio IDE," explains Visual Studio. It describes some of the IDE's useful features and shows how to build a simple program and run it. From the very first lesson, you'll be able to build a program!

Lesson 2, "Creating Controls," explains what controls are, what they are for, and how to use them. It shows how to add controls to a form to make a user interface. In Visual C# programs, controls are critical for getting the job done.

Lesson 3, "Making Controls Arrange Themselves," explains how to use control properties to make controls automatically rearrange themselves at run time to take full advantage of the available space. When the user resizes a form, the controls can automatically move and resize as needed.

Lesson 4, "Handling Events," explains what events are. It shows how to catch events to respond to user actions so the user can interact with the program.

Lesson 5, "Making Menus," explains how to add main menus and context menus to an application, and how to respond when the user selects a menu item. By responding to menu events, the program gives the user an easy and well-understood way to control the application.

Lesson 6, "Making Tool Strips and Status Strips," explains how to build tool strips and status strips, and how to handle their events. Tool strips provide a faster method for the user to control the application than menus, while status strips provide useful feedback to let the user know what the program is doing.

Lesson 7, "Using RichTextBoxes," explains the RichTextBox control and shows how to manipulate it with code. The RichTextBox allows the user to enter text and, if the program provides the right tools, lets the user format the text with different fonts, colors, bullets, and other text decorations.

Lesson 8, "Using Standard Dialogs," explains standard dialogs. It shows how to use them to display messages and questions, change fonts and colors, browse for folders, and let the user select files for opening and saving.

Lesson 9, "Creating and Displaying New Forms," explains how code can display new instances of forms and interact with the controls on those forms. This is important for more complicated programs that cannot do everything they need to on a single form.

Lesson 10, "Building Custom Dialogs," explains how to use new forms as custom dialogs. It shows how to use the Form object's ShowDialog method, how to assign a dialog's return result, and how to interpret that result.

Section II: Variables and Calculations

The lessons in this section deal with variables and calculations. They explain what variables are and how a program can use them to calculate results. The lessons in Section I explain how to make controls that let the user enter information. The lessons in this section explain how to take that information and do something with it.

Lesson 11, "Using Variables and Performing Calculations," explains how to declare and use variables and constants, and how to perform simple calculations. It also shows how to convert information from one data type to another. For example, it shows how to take an age entered by the user and convert it from the textual value "47" into the numeric value 47. (It's a small distinction to a person but a huge one to a program.)

Lesson 12, "Debugging Code," explains techniques for finding and fixing bugs. It shows how to set breakpoints in the code, step into and over routines, examine and modify variable values, and use watches. Almost every non-trivial program starts with a bug or two. This lesson shows how to find those bugs.

Lesson 13, "Understanding Scope," explains how scope restricts a variable's accessibility to pieces of code. It also explains why a programmer should restrict scope as much as possible.

Lesson 14, "Working with Strings," explains how to combine, manipulate, and format strings. It explains the String class's ToString and Format methods that let you build nicely formatted string to show the user.

Lesson 15, "Working with Dates and Times," explains how to use date and time values. It explains the Date and TimeSpan classes, and shows how to use and format them.

Lesson 16, "Using Arrays and Collections," explains single- and multi-dimensional arrays and collection classes such as Collection and ArrayList. It explains how to declare and initialize arrays and collections.

Lesson 17, "Using Structures and Enumerations," explains how to use more advanced data types such as structures and enumerations. These help make the code easier to understand, debug, and maintain.

Section III: Program Statements

The lessons in the previous sections explain how to let the user control the program by raising events, get data entered by the user in controls, place that data in variables, and perform simple calculations. The lessons in this section explain how to perform more complex calculations. They explain how to control the program's flow, make decisions, and repeat operations. While controls and message boxes are some of the more visible pieces of an application, these statements let the program do most of its work.

Lesson 18, "Making Choices," explains how programmers can control the flow of code with if, switch, nested if, and cascading if statements. These statements let the program take different actions depending on the situation.

Lesson 19, "Repeating Program Steps," explains looping code that uses for, foreach, do, and while statements. It explains how to use these statements to iterate through a series of integer values, arrays, and lists, and how to break out of loops.

Lesson 20, "Reusing Code with Functions," explains how a programmer can write functions and why functions are important. It explains the syntax of declaring functions, defining return values, and using parameters passed by value or reference.

Lesson 21, "Handling Errors," explains how to use try blocks to handle unexpected errors. It also explains how to throw errors to tell other parts of the program that something has gone wrong.

Lesson 22, "Preventing Bugs," explains bug proofing techniques that make it easier to detect and correct bugs. It explains how to use Assert statements to validate inputs and results so you can catch bugs quickly rather than letting them remain hidden in the code.

Section IV: Classes

Structures, enumerations, and functions are all programming abstractions that let you think about pieces of the program at a higher level. When you call the CalculateInterest function, you don't need to know how it works just that it does.

The ultimate programming abstraction is the class. A class lets you think about data and functions packaged as a single unit. For example, a Customer class might include data (name, employee ID, office number) together with functions (ScheduleWork, PrintPaycheck).

The lessons in this section deal with classes. They explain how to create and use classes and how to use more advanced class features such as generics and operator overloading.

Lesson 23, "Defining Classes," explains how to define classes. It explains the three fundamental characteristics of object-oriented classes (inheritance, encapsulation, and polymorphism) and how classes provide them. It explains how to build simple properties and methods.

Lesson 24, "Initializing Objects," explains constructors, destructors, and initializers, and shows how to use them to make creating objects easier.

Lesson 25, "Fine-Tuning Classes," explains how you can overload and override class methods. These techniques let you make classes more flexible and easier to use.

Lesson 26, "Overloading Operators," explains operator overloading. This technique lets you define the behavior of operators such as +, *, and % for objects other than numbers.

Lesson 27, "Using Class Interfaces," explains what a class interface is and how to build one. Just as a program's user interface defines the features that a user sees, a class interface defines the features that a class must have to implement the interface.

Lesson 28, "Making Generic Classes," explains how to build new generic classes. Lesson 16 shows how to use generic collection classes such as Hashtable to work with different kinds of data. This lesson explains how you can build your own generic classes and methods.

Section V: System Interactions

Earlier lessons explain how to let a program interact with the user. The lessons in this section explain methods a program can use to interact with the operating system and other programs.

Lesson 29, "Reading and Writing Files," explains how a program can read and write files. It explains how to use streams to manipulate the text in a file all at once or in pieces, for example, one line at a time.

Lesson 30, "Using Filesystem Classes," explains ways in which a program can use classes to find, examine, and manipulate directories and files. It describes file handling classes such as DriveInfo, DirectoryInfo, Directory, and FileInfo.

Lesson 31, "Printing," explains how to create printouts. It tells how to draw simple shapes and text on one or more pages sent to the printer.

Lesson 32, "Using the Clipboard," explains how to move text, images, and file drop lists in and out of the clipboard. Using the clipboard in this way is somewhat crude but it's simple and flexible, allowing your program to interact with many others without understanding anything about how those other applications work.

Lesson 33, "Providing Drag-and-Drop," explains how a program can use drag-and-drop to interact with other programs. It explains how to start a drag, provide "drag over" feedback, and handle a drop. Like the clipboard, drag-and-drop lets your programs interact with others without knowing how the other programs work.

Section VI: Specialized Topics

The lessons presented in the earlier sections cover topics that are generally useful for a large variety of programs. Whether you are writing a sales tax calculator, invoice tracking system, or word guessing game, techniques such as handling events, debugging code, using if statements, and printing will be useful to you.

This section introduces topics that are more specialized so you might not need them in every program you write. Localizing your application for different locales is important for some applications but not for every program you write.

Each of the lessons in this section gives a sense of what its topic is about and provides enough detail to get started, but the lessons cannot cover their topics in complete detail due to the topic's length and complexity.

Lesson 34, "Globalizing Programs," explains how to make programs that can run in multiple cultures. It shows how to use different text and images for different locales and discusses some of the other issues an international application must address.

Lesson 35, "Programming Databases, Part 1," explains how to use Visual Studio wizards to build a simple database application quickly. It shows how to display the data in a database and save any changes that the user makes.

Lesson 36, "Programming Databases, Part 2," explains slightly more advanced database features than those covered by Lesson 36. It explains how to make the simple programs described in Lesson 35 search, filter, and sort their results.

Lesson 37, "LINQ to Objects," explains how you can use Language-Integrated Query (LINQ) to filter and extract values from collections and other enumerable lists into new ones. This lets you perform database-like queries on data stored in program objects instead of an actual database.

Lesson 38, "LINQ to SQL," explains how you can use LINQ to manipulate database entities as if they were objects inside the program. It lets your program treat records in tables as if they were instances of classes, and provides an alternative database strategy to the one used in Lessons 35 and 36.

Lesson 39, "Drawing in GDI+," provides more detail about drawing with Graphic Device Interface (GDI+) functions. Previous lessons, notably Lesson 31, "Printing," used GDI+ functions to draw. These functions let you draw lines, rectangles, polygons, ellipses, curves, text, and other shapes on windows, bitmaps, and printouts. Those lessons provided only the bare minimum needed to demonstrate their topics. This lesson provides more detail so you can generate more complex graphics.

Lesson 40, "Making WPF Applications," explains Windows Presentation Foundation (WPF), a framework for building Window applications that provides an alternative to the Windows Forms applications described so far in this book. WPF applications provide new tools and approaches that let you build applications that are potentially more interactive and engaging.

Lesson 41, "Printing with WPF," explains one way you can generate printouts in WPF applications. It shows how to print an image of a WPF visual object, a much different methods than the event-driven technique used by the Windows Forms approach described in Lesson 31.

Appendices

This book's appendices summarize useful information for handy reference.

Appendix A, "Glossary," explains common programming terms that you may encounter while studying Visual C# programming.

Appendix B, "Control Summary," summarizes each of the standard controls provided by Visual C#. You can use it to help select the right control for your needs.