This repository contains explanations of various Object-Oriented Programming (OOP) concepts in C#. Each concept is described to help you understand and apply them in your projects.
- Encapsulation
- Inheritance
- Single Inheritance
- Multilevel Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance
- Polymorphism
- Compile-Time Polymorphism
- Run-Time Polymorphism
- Abstraction
Encapsulation is the concept of wrapping data and methods that operate on the data within a single unit, typically a class. It restricts direct access to some of the object's components, which can prevent the accidental modification of data.
Inheritance allows a class to inherit properties and methods from another class. It promotes code reusability and establishes a natural hierarchy between classes.
A class inherits from one base class.
A class is derived from a class which is also derived from another class.
Multiple classes inherit from a single base class.
A combination of two or more types of inheritance (achieved using interfaces in C#).
Polymorphism allows methods to do different things based on the object it is acting upon, even though they share the same name. It can be achieved through method overriding and method overloading.
Achieved through method overloading and operator overloading.
Achieved through method overriding using inheritance.
Abstraction is the concept of hiding the complex implementation details and showing only the necessary features of an object. It can be achieved using abstract classes and interfaces.