Chapter 4. Using Classes and Objects in C#

What Do We Use Classes For?

All C# programs are composed of classes. The Windows forms we have just seen are classes, derived from the basic Form class, and all the other programs we will be writing are made up exclusively of classes. C# does not have the concept of global data modules or shared data that are not part of classes.

Simply put, a class is a set of public and private methods and private data grouped inside named logical units. Usually, we write each class in a separate file, although this is not a hard and fast rule. We have already seen that these Windows forms are classes, and in this chapter we will see how we can create other useful classes.

When you create a class, it is not a single ...

Get C# Design Patterns: A Tutorial 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.