C# Abstract Class

Abstract class is a class which is declared abstract. In abstract class have abstract and non-abstract methods. When you inherit abstract class in other class then must provide implementation for abstract methods.

Abstract Class Implementation

Abstract class cannot be instantiated. You can create the abstract class using abstract keyword

public abstract class Shape
{
    public abstract void Draw();
}

public class Rectangle : Shape
{
    public override void Draw(){ // ... }
}

public class Circle : Shape
{
    public override void Draw(){ // ... }
}

Points to Remember

  • An abstract class contains abstract and non-abstract method.
  • An abstract class cannot be instantiated.
  • Abstract method must provide implementation in derived class.