Abstract class definition with example in C#.Net

Abstract Class 

Using Abstract keyword, we can create a class using C#.net. Main purpose of the Abstract class is for inheritance for defining the features of the non abstract and derived classes.

public abstract class IAmAbstract
//we will write class members here. 

Important points:

  • An abstract class can't be instantiated. 
  • Main purpose of the abstract class is to provide the common definition of the parent class to the multiple child classes. 
  • Abstract classes can have the abstract methods. Abstract methods don't have implementation. So, when ever we extend abstract class we have to implement this abstract method. 
  • When Abstract class is having the virtual method, still we want to use same method we can override the method.

Example Program:

// compile with: /target:library
public class ClassA
    public virtual void Work(int i)
        // Original implementation.

public abstract class ClassB : ClassA
    public abstract override void Work(int i);

public class ClassC : ClassB 
    public override void DoWork(int i)
        // New implementation.

See more OOPS dotnet Interview Questions
See more ASP.NET, C#.NET, Sql Server Interview Questions
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Featured post

JQuery Tutorial 1- Introduction to JQuery

If you have any queries or suggestions, please feel free to ask in comments section.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar