#oops Basic

  1. You cannot extend or inherit more than 1 abstract class (C# does not provides multiple inheritance.)
  2. Struct cannot implement an abstract class.
  3. Struct can implement interfaces.

class MyClass : a,b ---ERROR--Cannot implement multiple base class.


abstract class a


abstract class b


#Interfaces VS Abstract Class

Abstract class gives you all the benefits that interfaces does,except very  important one feature “Multiple Inheritance“. This is the sole reason why we are asked to write “program to an interface”.You would argue that i would load a constructor with a abstract class rather than interface,but it would fail since you cannot implement more than one class and you need interface to do that.Capture

#50-SOLID -Liskov Substitution Principle

Liskov Substitution Principle: SubType (Child Class)Must be Substitutable For Base Type(Base Class).

LSP comes into use when you use inheritance/Abstraction.


1.Child Class Should not remove Base Class Behaviour.

2.Child Class Should not violate base class invariants.

In short,the Calling code should not know whether it is calling the base class or derived class.