Osama Bin Gandhi Posted April 14, 2015 Report Posted April 14, 2015 When to use interface and abstract class anedi oka real time scenario ivvandi..
JasonBourne13 Posted April 14, 2015 Report Posted April 14, 2015 When to use interface and abstract class anedi oka real time scenario ivvandi.. In c#, there is no multiple inheritance. Interface can be used to achieve similar behavior. A class can inherit from multiple interfaces but not multiple classes. Practical example: In a firm, there are employees and there are departments such as HR, Facilities, Finance, Support, etc.. An employee can be a part of all of these departments. Example, Employee can have HR details, Finance details, Facilities subscriptions(sush as Transport, Gym, etc..) To implement this multiple inheritance kind of concept, you use Interfaces. Abstract classes are used to build modules which can be extended later on but this is a limitation(multiple inheritance kind).
KATHRI Posted April 14, 2015 Report Posted April 14, 2015 Enterprise applications lo code consistency kosam interface use Chesteru like if different web applications lo user, user role objects use cheste to maintain same code consistency these two classes will inherit the interface. (properties like firstname, lastname, userrole) ekkada implementation undadu.... oka vela different web pages same code (if the user is logged in and user has specific permission) use cheste they will write that method in abstract class and inherit from it...ekkada implementation untadi
Recommended Posts