Difference between Abstract class and Interface in C# .Net

Interfaces are essentially having all method prototypes no definition but Abstract class can contain method definations also.

In short Interface is a abstract class having all methods abstract.

Both abstract classes and interfaces are used when there is a difference in behaviour among the sub-types extending the abstract class or implementing the interface.

When the sub-types behaviour is totally different then you use an interface, when the sub-types behaviour is partially common and different with respect to the supertype an abstract class is used. In an abstract class the partially common behaviour is given a concrete implementation. Since there is no common behaviour between an interface and a sub-type an interface does not have an implementation for any of its behaviour.

If you create a abstract class writing the abstract keyword in the declaration part then You only can inherit the class. You can not create an instance of this abstract class but can inherit the class and with creating the instance of the derived class you can access the method of the abstract class.

If you use a virtual keyword in a method then you can override this method in the subclass if you wish..

If you create a abstract method then you must override this method in the subclass other wise it shows error in the program.

About Md Shaik Sadi

I am Md. Shaik Sadi, got my B.Sc.(Engg) degree in Computer Science and Engineering and started my carrer as a trainee developer. I have worked on different phases of software development life cycle. Recently, I am working on asp.net/2 and want to stablish my career on this platfrom.
This entry was posted in Computer Science and tagged , , , . Bookmark the permalink.

32 Responses to Difference between Abstract class and Interface in C# .Net

  1. shiman says:

    The concentration moved away from Interface towards Abstract Class. Better provide some examples… those would add extra values to the explanation.

  2. priya says:

    interface also have signature or definition.

    • badiuddin khan says:

      interface is fully abstract.means interface only and only contain the declaration of the methods,but definition implemented in the class.

  3. Gourishankar says:

    Short but hitting bulls eye…

  4. Pritpal Singh says:

    Good Post. Must read to get the Laymen Definition of the Interface and Abstract Class. A piece of code would make the post much much better.

  5. Mamta says:

    Good for beginners and graduate students like me.

  6. Arvind says:

    This is the best post on Abstract class and interface that i ever read on the net. very good effort….

  7. Joy says:

    sorry my friend is making fun of me.
    this is a good post

  8. NeeZ says:

    a very nice articel

  9. pratap says:

    its very good article……..

  10. prajwal says:

    better u people provide examples….Explanation along with examples will always be better.

  11. Abdurahman Gugssa says:

    My confusion about abstract vs interface goes away once and for all with this article.

    Good Job and thanks a lot.

  12. surendra says:

    Short and fine…….for first steppers

  13. Momin Ashfaque Ahemad says:

    Momin Ashfaque :
    I am very confused in abstract class and interface in c#.net ,so if any good example or idea about that topic so send on my e-mail.

    • arunkumar says:

      An abstract class can have abstract members as well non abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must override to its derived class.

      //All methods are automaticall abstract

      int AddNumbers(int Num1, int Num2);
      int MultiplyNumbers(int Num1, int Num2);
      Defining an abstract class with abstract members has the same effect to defining an interface.
      The members of the interface are public with no implementation. Abstract classes can have protected parts, static methods, etc.
      A class can inherit one or more interfaces, but only one abstract class.
      Abstract classes can add more functionality without destroying the child classes that were using the old version. In an interface, creation of additional functions will have an effect on its child classes, due to the necessary implementation of interface methods to classes.
      The selection of interface or abstract class depends on the need and design of your project. You can make an abstract class, interface or combination of both depending on your needs.

  14. dhanesh R says:

    Good but always mention examples then the programming language can easily understand

  15. Muhammad Ali says:

    Abstract is better then interface .. Interface do not have static method too

  16. Pankaj Rayal says:

    Nice post. really like it

  17. gangadhar says:


  18. Vikrant sharma says:

    interface class cannot implement Method only declare signature. ans support for multiple inheritance ,not use abstract or override the method
    Abstract class both have type method ,but abustruct method only give the definition not implement.but other methods is your choice

  19. Mansoor ul Haq says:

    Very nice post.
    It clears all my concepts related to Abstract class and interfaces.
    God Bless u..

  20. udhayam says:

    Abstract class atleast one method is unified.
    interface all method is unified

  21. Adesh Rajput says:

    Very nice post.
    It clears all my concepts related to Abstract class and interfaces.
    All the Best

  22. vanitha says:

    very nice.it clear my doubts.superb….

  23. vinay says:

    gud but one example makes it perfec……..understanding

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s