class Rectange
{
//public int width { get; set; }
// public int height { get; set; }
public virtual int width { get; set; }
public virtual int height { get; set; }
public Rectange()
{
}
public Rectange(int width, int height)
{
this.width = width;
this.height = height;
}
public override string ToString()
{
return $"{nameof(width)}:{width} .{nameof(height)}:{height}";
}
}
class Square:Rectange
{
// public new int width { set { base.width = base.height = value; } }
// public new int height { set { base.height = base.width = value; } }
public override int width {
set { base.width = base.height = value; }
}
public override int height {
set { base.height = base.width = value; }
}
}
internal class Program
{
static public int Area(Rectange r) => r.width * r.height;
static void Main(string[] args)
{
Rectange rc = new Rectange(2,3);
Console.WriteLine($"{rc} has a area {Area(rc)}");
Rectange square = new Square();
square.width = 4;
Console.WriteLine($"{square} has a area {Area(square)}");
}
}