namespace ConsoleApplication13
public Circle(double radius)
public double CalculateArea()
return Math.PI * radius * radius;
public Rectangle(double length, double width)
public double CalculateArea()
public static void Main(string[] args)
Circle circle = new Circle(5);
Rectangle rectangle = new Rectangle(4, 6);
Ishape shape1 = GetShape("circle");
Ishape shape2 = GetShape("rectangle");
Console.WriteLine(shape1.CalculateArea());
Console.WriteLine(shape2.CalculateArea());
static Ishape GetShape(String type)
if(type.ToLower()=="circle")
else if (type.ToLower()=="rectangle")
return new Rectangle(4,6);
throw new ArgumentException("Invalid Shape Type");