// I’ll draw anyone supporting IDraw3D. static void DrawIn3D( IDraw3D itf3d) { if(itf3d is IDraw3d) { Console.WriteLine("-> Drawing IDraw3D compatible type"); itf3d.Draw3D(); } }
// I’ll draw anyone supporting IDraw3D. static void DrawIn3D(IDraw3D itf3d) { if (itf3d is IDraw3d) { Console.WriteLine("-> Drawing IDraw3D compatible type"); itf3d.Draw3D(); } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Shape[] shapes = new Shape[] { new Triangle(), new Hexagon() }; foreach (Shape shape in shapes) { if (shape is IPointy) { ((IPointy)shape).Draw(); } IDraw3D idraw3d = shape as IDraw3D; if (idraw3d != null) { //Draw "normally" idraw3d.Draw3D(); //Draw as interface parameter DrawIn3D(idraw3d); } } Console.ReadLine(); }
static void DrawIn3D(IDraw3D itf3d) { itf3d.Draw3D(); }
// I'll draw anyone supporting IDraw3D. static void DrawIn3D(IDraw3D interface3d) { Console.Write("-> Drawing IDraw3D compatible type: "); interface3d.Draw3D(); }
static void DrawIn3D(IDraw3D i3d) { Console.WriteLine($"-> Drawing IDraw3D compatible type {i3d.GetType().Name}"); i3d.Draw3D(); }
// I'll darw anyone supporting IDraw3D static void DrawIn3D(IDraw3D<Shape> itf3d) { Console.WriteLine("-> Drawing IDraw3D compatible type"); itf3d.Draw3D(); }
// INTERFACE AS PARAMETERS public static void Draw3DShapes(IDraw3D shape) { shape.Draw3D(); }
static void DrawIn3D(IDraw3D itf3D) { Console.WriteLine("->Drawing IDraw3D compatible type."); itf3D.Draw3D(); }
// I'll draw anyone supporting IDraw3D. static void DrawIn3D(IDraw3D itf3D) { Console.WriteLine("-> Drawing IDraw3D compatible type"); itf3D.Draw3D(); }
//I'll draw anyone supporting IDraw3D static void DrawIn3D(IDraw3D itf3d) { Console.WriteLine("=> Drawing IDraw3D compatimble type"); itf3d.Draw3D(); }
public static void DrawIn3D(IDraw3D itf3d) { Console.WriteLine("\n=> Drawing IDRaw3d compatible type"); itf3d.Draw3D(); }
static void DrawIn3D(IDraw3D draw3D) { Console.WriteLine("Drawing IDraw3D compatible type"); draw3D.Draw3D(); }
private static void DrawIn3D(IDraw3D idrawin3d) { Console.WriteLine($"-> Drawing {idrawin3d.GetType().ToString()} compatible type..."); idrawin3d.Draw3D(); }