// 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();
        }
示例#4
0
 static void DrawIn3D(IDraw3D itf3d)
 {
     itf3d.Draw3D();
 }
示例#5
0
 // I'll draw anyone supporting IDraw3D.
 static void DrawIn3D(IDraw3D interface3d)
 {
     Console.Write("-> Drawing IDraw3D compatible type: ");
     interface3d.Draw3D();
 }
示例#6
0
 static void DrawIn3D(IDraw3D i3d)
 {
     Console.WriteLine($"-> Drawing IDraw3D compatible type {i3d.GetType().Name}");
     i3d.Draw3D();
 }
示例#7
0
 // 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();
 }
示例#9
0
 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();
 }
示例#11
0
 //I'll draw anyone supporting IDraw3D
 static void DrawIn3D(IDraw3D itf3d)
 {
     Console.WriteLine("=> Drawing IDraw3D compatimble type");
     itf3d.Draw3D();
 }
示例#12
0
 public static void DrawIn3D(IDraw3D itf3d)
 {
     Console.WriteLine("\n=> Drawing IDRaw3d compatible type");
     itf3d.Draw3D();
 }
示例#13
0
 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();
 }