Click here to Skip to main content
14,937,945 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
if we have abstract class having all method abstract and an interface having some method ,then what is the difference between this class and this interface
Posted

The difference doesn't necessarily apply at that class level - it applies at the level of the class that inherits it. If you have a totally abstract base class then your derived class can only derive from that one class, it cannot derive from any others. With an interface, your class can implement multiple interfaces as well as being derived from another class.

If, however, your abstract class contains abstract properties/methods, but also provides fields, your derived classes get access to these fields - interfaces cannot provide fields. Also, your abstract class may provide constructors which must be inherited - again, something you can't do with an interface.
   
What you are talking about is a bad coding pratique because C# only support single inheritance then, if you write an abstract class without implement no methods on that, you will be not able to inherit from that abstract class and from another class together.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900