How This Book Is Organized

Here’s a short summary of the chapters in this book and what you’ll find inside:

Chapter 1, C# and .NET Programming

Here, we’ll introduce you to the C# language and the .NET platform that supports it. That’s important background information so that you can see how C# fits into the larger scheme. More important, though, we’ll get you started writing real code. You’ll create your first working program and see how easy it is to program in C#.

Chapter 2, Visual Studio 2008 and C# Express 2008

When you build something, be it a house, a book, or a program, you have to know your tools. The tools for C# are Visual Studio 2008 and its free counterpart, C# Express. In this chapter, we’ll walk you through them so that you’re more comfortable with the interface.

Chapter 3, C# Language Fundamentals

Now that you have your feet wet, it’s time to begin at the beginning. In this chapter we’ll introduce the most basic concepts of C#: statements, types, and variables. We’ll also discuss constants and enumerations. And because you want your code to show you something, we’ll demonstrate strings and how to write to the screen.

Chapter 4, Operators

After you’ve learned about variables, you’ll want to do something with them, and that’s where operators come in. We’ll start with the most basic operator, for assignment, and then we’ll show you the mathematical operators, and the operators for comparison.

Chapter 5, Branching

Without branching, your program would proceed in a straight line from start to finish. Branching lets your program respond to the values contained in your variables, often using the comparison operators. You’ll also learn about the various looping statements that you’ll use quite often to carry out an action several times.

Chapter 6, Object-Oriented Programming

Object-oriented programming is what makes C# a modern programming language. It’s a different way of thinking about programming than you’ve been learning in the previous five chapters, but it’s a natural outgrowth too. In this chapter, we’ll put aside the coding for just a bit and talk about what object orientation means, and why it matters to you.

Chapter 7, Classes and Objects

Classes, and the objects you get from classes, are the foundation of object-oriented programming. Now that you have the theory down, this chapter lets you get your hands dirty with objects: creating them, using them, and seeing how they work.

Chapter 8, Inside Methods

You’ve been using methods through all the preceding chapters, but after learning about objects, it’s time to find out a little more about methods and how they interact with objects. You’ll find out about what you put into methods and what comes back out, how to overload methods to make them more versatile, and how properties make writing methods easier.

Chapter 9, Basic Debugging

Stuff goes wrong, in life and in code. At this point in the book, you know enough to be dangerous, which means you’ll have generated some errors. Fortunately, Visual Studio has a bunch of tools to make errors easier to find and fix. We’ll show you how to do that now, to increase your peace of mind for the rest of the book.

Chapter 10, Arrays

If objects are good, a bunch of objects, all of the same type, can be better. This chapter shows you a special language feature, called an array, that lets you handle lots of objects as a group.

Chapter 11, Inheritance and Polymorphism

As you’ll learn in Chapter 6, specialization and generalization are two key components of object-oriented programming, and C# implements them with inheritance and polymorphism. You’ll see how you can use classes to beget other classes for specialized purposes.

Chapter 12, Operator Overloading

When you create your own classes, you’ll often need a way to define whether one of your objects is equal to another. You can do that by defining just what “equal” means for your class, and from there, you can define the = operator itself, for your class. You’ll see how to redefine other operators as well.

Chapter 13, Interfaces

Interfaces build on the concepts of inheritance and polymorphism introduced in Chapter 11. An interface is a contract that states what a class that implements that interface can do, and how to interact with it. That flexibility lets you work with objects without knowing exactly what types they are, as long as you know what interfaces they use.

Chapter 14, Generics and Collections

This chapter puts together what you learned in Chapters Chapter 10, Chapter 11, and Chapter 13. Collections are another way of keeping bunches of objects together, but with generics, you don’t need to know exactly what type of objects you have in your collection; interfaces make that possible.

Chapter 15, Strings

This chapter is all about text, which C# refers to as strings. Strings are a bit more complicated than other data types, but you can do some very interesting manipulation with them, as you’ll find out.

Chapter 16, Throwing and Catching Exceptions

Your code runs in an imperfect world, which means sometimes things will go wrong. Users will enter bad data, network connections will go down, and files will vanish without warning. However, just because something goes wrong doesn’t mean your program has to crash. In this chapter you’ll learn how to anticipate certain error conditions and allow for them.

Chapter 17, Delegates and Events

Up to this point, your methods have called other methods specifically. With events, and the delegates that work with them, your object can simply announce that something has happened, and let any other interested objects worry about what to do next. Events are the foundation of how the Windows operating system works.

Chapter 18, Creating Windows Applications

With knowledge of events in your hand, it’s time to have some fun and write a Windows application or two. The topic of Windows applications could warrant an entire book on its own, but we’ll get you started in this chapter.

Chapter 19, Windows Presentation Foundation

The Windows Presentation Foundation (WPF) is a new feature that gives you more control over just how your applications look to the user. WPF offers a lot of enhancements over Windows Forms, and we’ll show you a few of them in this chapter.

Chapter 20, ADO.NET and Relational Databases

All the code you’ve written in the book so far has used short-lived data that vanishes as soon as the program ends. In the real world, data is stored in databases, and in this chapter, you’ll see how to interact with them.

Chapter 21, LINQ

Language Integrated Query (LINQ) is a new feature in C# 3.0 that greatly simplifies how your code interacts with data storage. Most interesting of all, you can use it to access data stored elsewhere in the same program. This is another topic that could warrant a book in itself, but we’ll introduce you to it here.

Appendix, Answers to Quizzes and Exercises

The appendix features the answers to every quiz question and exercise found in the book. We’ll provide the complete code for the answers, but more important, we’ll explain why the answers are what they are.

Get Learning C# 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.