Talking About OOP
Learn about object-oriented programming concepts: composition, aggregation, inheritance, abstraction, and polymorphism.
We'll cover the following
An object in the real world is a thing, such as a car or a person, whereas an object in programming often represents something in the real world, such as a product or bank account, but it can also be more abstract.
In C#, we use the class
and record
(mostly) or struct
(sometimes) C# keywords to define a type of object. We will learn about the difference between classes and structs later. We can think of a type as a blueprint or template for an object.
Concepts of OOP
The concepts of OOP are briefly described here:
Encapsulation is the combination of the data and actions related to an object.
For example, a BankAccount type might have data, such as Balance and
AccountName
, and actions likeDeposit
andWithdraw
. When encapsulating, we often want to control what can access those actions and the data; for example, restricting how the internal state of an object can be accessed or modified from the outside.
Get hands-on with 1400+ tech skills courses.