Posted: 8/19/2010
I want to know why Inteface come in picture except multiple inheritance.
For example
public interface IABC{ void GetName();}public abstract class XYZ{ public abstract void GetName();}
above senario both method are mendatory to implement/override. both look like same
then why they add Interface. except use of multiple inheritance?
Please share your thoughts....
Check out this blog post:
http://codeasp.net/blogs/vivek_iit/microsoft-net/430/abstract-classes-vs-interfaces-c
I have red that article.. but i did not find answer..
if we can achive same or better thing through abstract. why interface come in to the picture.. ? except multiple inhertiance.
sanjayjgoswami said: user="sanjay goswami"]if we can achive same or better thing through abstract. why interface come in to the picture.. ?
user="sanjay goswami"]if we can achive same or better thing through abstract. why interface come in to the picture.. ?
Looks like you did not read that article properly:
In .NET you can derive from multiple interfaces, but then with time you might have a lot of interfaces created just to accomodate the extra features you developed over time and this can cause maintenance as well as performance issues. Hence you need to spend good amount of time while re-factoring your exisitng code into interfaces to make sure you have captured each and every functionality possible in your interface.
so if you dont need to support multiple intheritance, simply go with abstract classes. It is pretty simple.
Thanx.
I am asking is any other reason to use Interface,(not about multiple Inhertiance)?
If no then you mean to say interface is only add for achive multiple Inhertiance, If interface is only for multiple inhertinace then what is the reason mutliple inhertinace functionality not achiveable with normal class or ther class?
sanjayjgoswami said: user="sanjay goswami"]I am asking is any other reason to use Interface,(not about multiple Inhertiance)?
user="sanjay goswami"]I am asking is any other reason to use Interface,(not about multiple Inhertiance)?
Interfaces guarantee that there is no default functionality in the "blue print" definition. If your program will never change in terms of basic functionalities offered, its best to use Interfaces so that your program can be easily extended.
But if you think your program will have new features added later, then you have to use abstract classes so that you can have some default functionalities. Note that is becomes difficult for 3rd party developers to change their code if you use abstract classes code for new fucntionalities. So it depends on when to use interfaces or abstract classes.
Posted: 9/16/2010
hi sanjay check this blog post may it help's you
http://aspdotnet-suresh.blogspot.com/2010/04/abstract-versus-interface.html