public static void Main()
var rect = new Rectangle { Height = 10, Length = 5 };
var area = CalculateAreaSwitchStatement(rect);
Console.WriteLine($"Area = {area}");
static double CalculateAreaSwitchStatement(object obj)
throw new ArgumentNullException(nameof(obj));
case Circle { Radius: 0 }:
case Rectangle { Length: 0 }:
case Rectangle { Height: 0 }:
case Triangle { Base: 0 }:
case Triangle { Height: 0 }:
case Square { Side: var s }:
case Circle { Radius: var r }:
case Rectangle { Length: var l, Height: var h }:
case Triangle { Base: var b, Height: var h}:
throw new NotSupportedException();
public double Side { get; set; }
public double Radius { get; set; }
public double Length { get; set; }
public double Height { get; set; }
public double Base { get; set; }
public double Height { get; set; }