Fundamentals of Computer Programming with C# HTML version

Chapter 11. Creating
and Using Objects
In This Chapter
In this chapter we are going to get familiar with the basic concepts of object-
oriented programming – classes and objects – and we are going to explain
how to use classes from the standard libraries of .NET Framework. We are
going to mention some commonly used system classes and see how to create
and use their instances (objects). We are going to discuss how we can
access fields of an object, how to call constructors and how to work with
static fields in classes. Finally, we are going to get familiar with the term
"namespaces" – how they help us, how to include them and use them.
Classes and Objects
Over the last few decades programming and informatics have experienced
incredible growth and concepts, which have changed the way programs, are
built. Object-oriented programming (OOP) introduces such radical idea.
We are going to make a short introduction to the principles of OOP and the
concepts used in it. Firstly, we are going to explain what classes and objects
are. These two terms are basic for OOP and inseparable part from the life of
any modern programmer.
What Is Object-Oriented Programming?
Object-oriented programming (OOP) is a programming paradigm, which uses
objects and their interactions for building computer programs. Thus an easy
to understand, simple model of the subject area is achieved, which gives an
opportunity to the programmer to solve intuitively (by simple logic) many of
the problems, which occur in the real world.
For now we are not going to get into details what the goals and the
advantages of OOP are, as well as explaining in details the principles for
building hierarchies of classes and objects. We are going to mention only that
programming techniques of OOP often include encapsulation, abstraction,
polymorphism and inheritance. These techniques are out of the goals of
the current chapter and we are going to consider them later in the chapter
"Principles of Object-Oriented Programming". Now we will focus on objects as
a basic concept in OOP.