Inheritance | OOP
Inheritance is one of the core concepts of object-oriented programming (OOP) that allows a class (called a subclass or derived class) to inherit the properties and behaviors (fields and methods) of another class (called a superclass or base class). This promotes code reuse and the creation of a hierarchical relationship between classes. Example in C#: class Program { static void Main() { // Create an instance of the Dog class Dog dog = new Dog(); dog.Name = "Buddy" ; // Access methods from the base class dog.Eat(); // Access methods from the derived class dog.Bark(); } } In this example: - `Animal` is the base class with a property `Name` and a method `Eat`. - `Dog` is the derived class that inherits from `Animal` and adds a method `Bark`. When we create ...