Sobes.tech
Junior — Middle

How is class inheritance implemented in the .NET platform?

sobes.tech AI

Answer from AI

In the .NET platform, class inheritance is implemented using the : keyword. A class can inherit from one base class and implement multiple interfaces.

Example of inheritance:

// Base class
public class Animal
{
    public void Eat() {
        Console.WriteLine("Eating...");
    }
}

// Derived class inherits from Animal
public class Dog : Animal
{
    public void Bark() {
        Console.WriteLine("Bark!");
    }
}

// Usage
Dog dog = new Dog();
dog.Eat(); // method of the base class
 dog.Bark(); // method of the derived class

Thus, inheritance in .NET allows extending the functionality of the base class in derived classes.

How is class inheritance implemented in the .NET… - sobes.tech