An abstract class is a class that cannot be instantiated and is typically used as a base class for other classes. It defines a common interface for its subclasses, but may also contain some implementation details. An abstract class can have abstract and non-abstract methods (abstract methods do not have a body).

An abstract class is similar to an interface in that it defines a contract for subclasses to implement, but it also allows for some implementation details to be shared among subclasses. Unlike interfaces, an abstract class can have state (fields) and can provide a default implementation for some of the methods.

An abstract class can not be instantiated, it is designed to be inherited by other classes.

Here is an example of an Abstract class:

abstract class Animal
{
    public string Name { get; set; }
    public int Age { get; set; }

    public Animal(string name, int age)
    {
        Name = name;
        Age = age;
    }

    public abstract void MakeNoise();
}

This class has a name and an age properties, both are strings, and it has a constructor that accepts a name and an age as arguments. It also has an abstract method called MakeNoise() which will be implemented by derived classes.

An abstract class is a class that cannot be instantiated, it is only meant to be inherited by other classes. In this case, the Animal class cannot be instantiated on its own, but it can be used as a base class for other animal classes such as Dog, Cat, Lion, etc. Each derived class can provide their own implementation of the MakeNoise() method.

class Dog : Animal
{
    public Dog(string name, int age) : base(name, age) { }

    public override void MakeNoise()
    {
        Console.WriteLine("Woof woof!");
    }
}

This is an example of a class that inherits from the Animal class, this class is called Dog, it has its own constructor that calls the base class constructor to initialize the name and age properties and it implements the MakeNoise method.

We can then instantiate the Dog class like so and utilize the Abstract Animal class that we created:

class Program
{
    public static void Main(string[] args)
    {
        Dog dog = new Dog("Gatsby", 2);
        Console.WriteLine($"Dog Name: {dog.Name} - Dog          Age: {dog.Age}");
        dog.MakeNoise(); 
    }
}

I hope you found this article helpful on Abstract classes.