Translate

Wednesday, April 10, 2013

Difference between abstract class and interface c#

Abstract Class
Interface


An abstract class can have method implementations.
An interface cannot have method implementations.
An abstract class can have fields.
An interface cannot have fields
A class can implement only one abstract class.
A class can implement multiple interfaces.
An abstract class tells you what you are. For example if a Person class that implements an abstract class mammal, then that means every person is a mammal.
An interface is merely a feature and doesnot define who you are. For example if your class implements interface IPrint, that does not mean your class is a printer. All it says is that your class have a print feature.


No comments:

Post a Comment

Comments will appear once they have been approved by the moderator