Chapter 5. Getting into Object-Oriented Programming

In This Chapter

Looking at what object-oriented programming is

Understanding objects and classes

Creating your own classes

Working with fields and properties

Overloading your methods

Concocting constructors

Using static members

This chapter is a basic introduction to the object-oriented programming features of C#. We’re talking basic here, not comprehensive; object-oriented programming is easily enough for a book of its own. But you’ve come to the right place for a look at creating and using your own classes.

What Is Object-Oriented Programming?

The term object-oriented programming means many different things — but at its heart, this type of computer programming organizes code into logical objects, on the premise that all programs are essentially computer-based simulations of real-world objects — or of abstract concepts that can be made to work like objects. Here are some examples:

  • Flight-simulator programs attempt to mimic the behavior of real airplanes. Some do an amazingly good job; military and commercial pilots train on them. In the 1960s, the Apollo astronauts used a computer-controlled simulator to practice moon landings — these days, even inexpensive flight simulator programs that run on PCs (and cost about $50) do a pretty credible job.

  • Many computer games are simulations of actual games humans play, such as baseball, NASCAR racing, and chess. But even abstract games such as Pacman or World of Warcraft attempt to model the ...

Get ASP.NET 2.0 All-In-One Desk Reference For Dummies® 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.