xviii Introduction
My goal is to provide you with the “dungeon map” to direct you as you begin delving into C#, while
still allowing you to mostly explore whatever you want, whenever you want.
I want to point out that this book is intentionally not called Everything you Need to Know about C#, or
The Comprehensive Guide to C#. (Note that if books with those titles actually exist, I’m not referring to
them specifically, but rather, to just the general idea of an all-encompassing book.) I’m here to tell
you, when you’re done with this book, you’ll still have lots to learn about C#.
But guess what? That’s going to happen with any book you use, including those all-encompassing
books. Programming languages are complex creations, and there are enough dark corners and
strange combinations that nobody can learn everything there is to know about them. In fact, I’ve
even seen the people who designed the C# language say they just learned something new about it!
For as long as you use C#, you’ll constantly be learning new things about it, and that’s actually one of
the things that makes programming interesting.
I’ve tried to cover a lot of ground in this book, and with roughly 350 pages, anyone would expect that
to be quite a bit. And it is. But there are plenty of other books out there that are 800 or even 1200
pages long. A book so heavy, you’ll need a packing mule to carry it anywhere. That, or permanently
place it on the central dais of an ancient library, with a single beam of dusty light shining in on it
through a hole in the marble ceiling. Instead of all that, the goal of this book is effectiveness and
clarity, not comprehensiveness. Something that will fit both on your shelf and in your brain.
It is important to point out that this book is focused on the C# programming language, rather than
libraries for building certain specific application types. So while you can build desktop applications,
web pages, and computer games with C#, we won’t be discussing WPF, ASP.NET, DirectX, or any
other platform- or framework-specific code. Instead, we’ll focus on core C# code, without bogging
you down with those additional libraries at first. Once you’ve got the hang of C#, heading into one of
those areas will be much easier.
How This Book is Organized
This book is divided into six parts. Part 1 describes what you need to get going. You’ll learn how to
get set up with the free software that you need to write code and make your first C# program.
Part 2 describes the basics of procedural programming—how to tell the computer, step-by-step,
what to do to accomplish tasks. It covers things like how information is stored (in variables), how to
make decisions, loop over things repeatedly, and put blocks of code that accomplish specific tasks
into a reusable chunk called a method. It also introduces the type system of the C# language, which
is one of the key pieces of C# programming.
Part 3 goes into object-oriented programming, introducing it from the ground up, but also getting
into a lot of the details that make it so powerful. Chapter 18, in my opinion, is the critical point of the
book. It is where we get into the details of making your own classes, which is the most powerful way
C# provides for building your own data types. Everything before this point is giving us the building
blocks that we need to understand and make classes. Everything that we do after is simply providing
us with more ways to use these custom-made types or showing how to use other classes that have
been made by others.
Part 4 covers some common programming tasks, as well as covering some of the more advanced
features of C#. For the most part, these topics are independent of each other, and once you’ve made
it past that critical point in Chapter 18, you should be able to do these at any time you want.