Beispiel #1
0
        static void Main(string[] args)
        {
            person[] p = new person[3];
            p[0] = new programmer();
            p[1] = new singer();
            p[2] = new dancer();

            for (int i = 0; i < p.Length; i++)
            {
                perform(p[i]);
            }


            Console.ReadLine();
        }
 static void Main(string[] args)
 {
     Person[] p = new Person[3];
     p[0] = new Programmer();
     p[1] = new singer();
     p[2] = new dancer();
     foreach (Person person in p)
     {
         Console.WriteLine(person.dojob());
         if (person is Programmer)
         {
             ((Programmer)person).test();
         }
     }
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            person[] p = new person[3];
            p[0] = new programmer();
            p[1] = new singer();
            p[2] = new dancer();

            for (int i = 0; i < p.Length; i++)
            {
                Console.WriteLine(p[i].dojob());
                if (p[i] is programmer)
                {
                    programmer p1 = (programmer)p[i];
                    p1.testing();
                }
            }
        }