using static System.Console;
namespace DotNetDesignPatternDemos.SOLID.LiskovSubstitutionPrinciple
public int Width { get; set; }
public int Height { get; set; }
public Rectangle(int width, int height)
public override string ToString()
return $"{nameof(Width)}: {Width}, {nameof(Height)}: {Height}";
public class Square : Rectangle
set { base.Width = base.Height = value; }
set { base.Width = base.Height = value; }
static public int Area(Rectangle r) => r.Width * r.Height;
static void Main(string[] args)
Rectangle rc = new Rectangle(2,3);
WriteLine($"{rc} has area {Area(rc)}");
Rectangle sq = new Square();
WriteLine($"{sq} has area {Area(sq)}");