Abstract Class
Abstract class means, We cannot create the object of this class or no object of this class can be instantiated. We can derive its sub classes which can be instantiated. An abstract class can contain either abstract or non-abstract members. Abstract class , marked by the keyword abstract.
Declaration of abstract class:
- abstract class DemoAbstract
- {
- }
Abstract Method :
An abstract method does not have any implement in abstract class. It has to be providing in its derived class and marked by the keyword abstract.
- abstract class DemoAbstract
- {
- public abstract void addTowNumber();
- public int AddThreeNumber(int a, int b, int c)
- {
- return a + b + c;
- }
- }
Note : An abstract calss does not mean that is should contain abstract member We can have an abstract class only with non-abstract member.
- abstract class DemoAbstract
- {
- public int AddThreeNumber(int a, int b, int c)
- {
- return a + b + c;
- }
- }
Example
- abstract class DemoAbstract
- {
- /// abstract Properties
- protected String _Myname;
- public abstract String Myname
- {
- get;
- set;
- }
- /// abstract Methods
- public abstract void addTowNumber(int a, int b);
- public int AddThreeNumber(int a, int b, int c)
- {
- return a + b + c;
- }
- }
- class DemoDerived : DemoAbstract
- {
- // implementing abstract method
- public override void addTowNumber(int a, int b)
- {
- Console.WriteLine(a + b);
- }
- // implementing abstract Member
- public override String Myname
- {
- get
- {
- return _Myname;
- }
- set
- {
- _Myname = value;
- }
- }
- }
Note
- An abstract method and properties cannot be static.
- An abstract method and properties cannot be private.
- An abstract class cannot be sealed calss.
- An abstract method and properties cannot have modifier virtual.

Purushottam RathorePosted Dec 15, 2014, 4:17 AM
Thanks Yogesh. Your Note is very clear and informative.
preet singhPosted Dec 15, 2014, 2:37 AM
Nice informative...
Jitendra KumarPosted Dec 14, 2014, 12:03 PM
Good article..