using System;
// Goal: Calls a method GetShape() which returns some time which can draw
public class Program
{
public static void Main()
Console.WriteLine("Calling GetShape()...");
// Call the GetShape() method to get an object reference of some time which can draw
<<SOME_TYPE>> = GetShape(1);
// call the Draw() method of that object to draw the actual shape
<<SOME_TYPE>>.Draw();
}
// Returns a type which can Draw() based on input param
// 1 = Circle, 2 = Triangle
public static <<SOME_TYPE>> GetShape(int val)
<<SOME_TYPE>> ret = null;
//
if(val == 1)
ret = new Circle();
else
ret = new Triangle();
return ret;
public class Circle
public void Draw()
Console.WriteLine("Drawing Circle");
public class Triangle
Console.WriteLine("Drawing Triangle");