C# OOP

C# - What is OOP?

OOP stands for Object-Oriented Programming.

Procedural programming is about writing procedures or methods that perform operations on the data, while object-oriented programming is about creating objects that contain both data and methods.

Object-oriented programming has several advantages over procedural programming:

  • OOP is fast and easy to use
  • OOP provides a clear framework for programs
  • OOP helps keep the code C # DRY "Do not repeat", and makes the code easy to save, correct and debug.
  • OOP makes it possible to create fully reusable applications with minimal code and short upgrade time

C# - What are Classes and Objects?

Classes and objects are two main elements of object-oriented programming.

Look at the following picture to see the difference between class and objects:

class

Fruit

objects

Apple

Banana

Mango

Another example:

class

Car

objects

Volvo

Audi

Toyota

So, a class is a template of objects, and an object is an instance of a class.

When each item is created, it inherits all variables and methods from the class.