Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a small doubt. where we will use exactly interfaces and abstract classes in project.


Can any one clarify me...please.
Posted

 
Share this answer
 
And what research have you done?

An interface is a contract, it contains no code. An Abstract class can have code. In .NET you can't derive from multiple classes however you can implement multiple interfaces.

Abstract Class versus Interface[^]
 
Share this answer
 
I already answered similar question. In addition to other Answers, please see the discussion on how to decide on use of interfaces vs. abstract classes: How to decide to choose Abstract class or an Interface[^].

Also, one fundamental difference is that interfaces allows for multiple inheritance, in contrast to classes (abstract or not). This is called week form of multiple inheritance and has serious design implications.

—SA
 
Share this answer
 
v3
Comments
rajivpande86 1-Mar-11 18:17pm    
Not in a mood to raise a debate, still I just want to say -though we iterate 1000 times that we can't go for multiple inheritance but can implement multiple interfaces in C#;implementing multiple interfaces is in no way, even comparable, to multiple inheritance.Implementing multiple interfaces is just that we are adding more constraints to our class to bind to.Your opinion awaited!!
Sergey Alexandrovich Kryukov 1-Mar-11 23:10pm    
This is called weak form of multiple inheritance; if you look at VMT layout you would see it is a special case of inheritance (not just by syntax); "comparable" is something undefined and does not make any interesting subject of discussion; and interfaces have nothing to do with constraints. Franky, I'm not very interested in exchange of any opinions on the topic. (What I've just written was not an "opinion".)
--SA
this[^] might give you an idea.
 
Share this answer
 

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