Abstract Class in C#

In this article, I’m trying to explain the concept of abstract class.

An Abstract class is an incomplete class or special class we can't instantiate. We can use an Abstract class as a Base Class. An Abstract method must be implemented in the non-Abstract class using the override keyword. After overriding the abstract method is in the non-Abstract class. We can derive this class in another class and again we can override the same abstract method with it. 

The purpose of abstract class is to provide default functionality to its sub classes.

When a method is declared as abstract in the base class then every derived class of that class must provide its own definition for that method.

 An abstract class can also contain methods with complete implementation, besides abstract methods.

When a class contains at least one abstract method, then the class must be declared as abstract class. 

It is mandatory to override abstract method in the derived class.

When a class is declared as abstract class, then it is not possible to create an instance for that class. But it can be used as a parameter in a method.


1.       An abstract class can inherit from a class and one or more interfaces.

2.       An abstract class can implement code with non-Abstract methods.

3.       An Abstract class can have modifiers for methods, properties etc.

4.       An Abstract class can have constants and fields.

5.       An abstract class can implement a property.

6.       An abstract class can have constructors or destructors.

7.       An abstract class cannot be inherited from by structures.

8.    An abstract class cannot support multiple inheritance.


using System;

namespace AbstractClassConsoleApplication


    /// <summary>

    /// declare an abstract class with keyword abstract

    /// </summary>

    abstract class Abstract


        /// <summary>

        /// declare abstract methods

        /// </summary>

        public abstract void area(int l, int b);

        public abstract void circumference(int l, int b);


    class Rectangle : Abstract //inherits abstract class


        /// <summary>

        /// override abstract methods in derived class and give definition

        /// </summary>

        /// <param name="l">length of rectangle</param>

   /// <param name="b">breadth of rectangle</param>

        public override void area(int l,int b)


            Console.WriteLine("Area of Square : "+(l*b));


        public override void circumference(int l,int b)


            Console.WriteLine("Circumference : " +(2*(l+b)));



    class Program


        static void Main(string[] args)


            Rectangle rec = new Rectangle(); // create object

            Console.Write("Enter Length=");

            int l = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter width=");

            int b = Convert.ToInt32(Console.ReadLine());

            rec.area(l,b); //calls the method

            rec.circumference(l,b); //call the method




Output :-

Enter Length=12

Enter width=9

Area Of Rectangle=108


In this example, I have declared an abstract class with two abstract methods – area() and circumference(). Rectangle class inherits the abstract class and gives the definition to the abstract methods. In program class create object of rectangle class and call both the methods.

Leave Comment