Introduction
An Abstract class is a class that cannot be instantiated. An Abstract keyword enables you to create classes and class members that are incomplete and must be implemented in derived class.
An abstract class can contain abstract methods,non abstract methods,fields,constant,properties,constructor and destructor.
The purpose of abstract class is to provide a common definition of a base class that multiple derived class can use.
Class can be declared as Abstract by putting Abstract before the class definition.
For Example:
Abstract class classname
{
// code comes here
}
Method can be declared as abstract by adding the keyword abstract before the return type of method.
Imp: Abstract methods have no implementation,method definition is followed by semicolon instead of a method block. An Abstract method is implemented using override keyword.
Derive class of abstract class must implement all abstract methods otherwise it will generate an error.
Example:
program:
using System;
namespace abstractclass
{ public abstract class a
{
public abstract void m();
}
class Program : a
{
static void Main(string[] args)
{
Console.WriteLine("Hello
In main method");
Console.ReadKey();
}
}
}
generate an error " abstractclass.Program does not implement inherited abstract member abstractclass.a.m()"
correct program:
using System;
namespace abstractclass
{
public abstract class a
{
public abstract void m();
}
class Program : a
{
public override void m()
{
Console.WriteLine("abstract
class method");
}
static void Main(string[] args)
{
Program
p = new Program();
p.m();
Console.WriteLine("Hello
In main method");
Console.ReadKey();
}
}
}
output of the above program :

Important points regarding Abstract class and Abstract Method
- Abstract method cannot be declare static and if do so it will generate an error ( reason: because static method cannot be marked as override,abstract or virtual)
- Can not use sealed keyword with Abstract method.
- Abstract class cannot be made private.
Maruthi PalllamalliPosted Dec 16, 2015, 10:37 AM
What happen if Abstract class empty ?What we can do with empty abstract class ? I Hope, You can provide incomplete ness to any class not only to an abstract.
Tony YangPosted Nov 25, 2015, 3:57 AM
I do not agree with you about that "t consists of at least one member that may be a method or property that has a signature, but doesn't have an implementation or body.".
Kiranteja JallepalliPosted Jul 30, 2015, 12:04 PM
Thank you Rajeesh Menoth
Rajeesh MenothPosted Jul 30, 2015, 3:27 AM
Good Explanation, Thank you sir
Thiru SagadevanPosted May 20, 2015, 2:47 AM
The example you took, to explain was good but the way it was presented was not good. Because of the too much grammatical mistakes, people can not understand it easily.
Santhakumar MunuswamyPosted May 18, 2015, 2:11 PM
Thanks for nice one
Gowtham RajamanickamPosted May 18, 2015, 12:40 PM
informative..
Pankaj Kumar ChoudharyPosted May 18, 2015, 12:09 PM
Really nice way of explanation sir............
Haribansh Kumar AgrawalPosted May 18, 2015, 9:53 AM
nice explanation Mr. Kirantejja
Abhishek JaiswalPosted May 18, 2015, 9:34 AM
Very well explained and good example. :)