Thursday, March 23, 2023

when to Use Abstract class and when to use Interface Real time scenrios.

 When we have the requirement of a class that contains some common properties or methods with some common properties whose implementation is different for different classes, in that situation, it's better to use Abstract Class then Interface.

Abstract classes provide you the flexibility to have certain concrete methods and some other methods that the derived classes should implement. On the other hand, if you use interfaces, you would need to implement all the methods in the class that extends the interface. An abstract class is a good choice if you have plans for future expansion.

https://www.c-sharpcorner.com/article/when-to-use-abstract-class-and-interface-in-real-time-projects/




No comments:

Post a Comment