Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Posts Tagged ‘Interfaces

Abstract Classes Vs. Interface – Why and When

leave a comment »

As you know the difference between abstract class and interface, sometimes I wonder what to use in project.

Abstract Classes is similar to interface but might be with implementation.

Interface is without implementation, just interface or virtual methods.

As per my understanding, it is can-do or is-do relationship. Like, from .NET framework, there are many interface like IComparer, ISortable etc. So, it is something like, classes derived from the interface CAN-DO these things.

But if the abstract class is CompareBase and if you are deriving classes from this class named TestCompare, then you can say that TestCompare IS DOing CompareBase.

Actually, you can find awkward but if you think over it, you can get this concept easily. Also, when you are deriving from multiple inheritance, you can say like, this class CAN DO this and CAN DO that etc.

Hope You Getting This 😀

Written by Manish

April 20, 2009 at 11:20 pm