views:

85

answers:

4

Possible Duplicates:
Interface vs Base class
Abstract classes vs Interfaces

How can we take decision about when we have to use Interface and when Abstract Class..??

Any idea..??

Thank in advance!

+2  A: 

My rule of thumb is: Use an abstract class when there is shared code, otherwise use an interface.

Jerod Houghtelling
A: 

If you plan to have the same implementation of part of your methods and properties then use abstract class, if you want just to hold the same members in all classes, but with a diffrent implementation for all of them then use interface.

In other words use interface if some of your derived class methods should be exacaly the same in each derived class, otherwise use interface.

ŁukaszW.pl
+2  A: 

Do you want to provide a shared implementation of a method?

Use an abstract class.

Do you simply want to provide a contract that specifies what external functionality an object must provide?

Use an interface.

Justin Niessner
A: 

Have a look at this interesting article that will help you understand the differences between Interfaces and Abstract Classes on CodeProject.

tommieb75