In this article, I’m trying to explain the concept of
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.
purpose of abstract class is to provide default functionality to its sub
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.
/// declare an abstract class with keyword abstract
/// declare abstract methods
abstract void area(int
l, int b);
abstract void circumference(int
l, int b);
class Rectangle : Abstract
/// override abstract methods in derived class and give definition
/// <param name="l">length of rectangle</param>
/// <param name="b">breadth of rectangle</param>
override void area(int
Console.WriteLine("Area of Square : "+(l*b));
override void circumference(int
Console.WriteLine("Circumference : " +(2*(l+b)));
void Main(string args)
Rectangle rec = new Rectangle();
// create object
int l = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
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.