static void Main(string[] args)
        {
            List <BaseClass> MyClasses = new List <BaseClass>();

            MyClasses.Add(new DerivedClass());
            MyClasses.Add(new AnotherDerivedClass());
            foreach (BaseClass MyClasse in MyClasses)
            {
                Console.WriteLine(MyClasse.GetType());
                MyClasse.A();
            }
            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            List <BaseClass> MyClasses = new List <BaseClass>();

            MyClasses.Add(new DerivedClass());
            MyClasses.Add(new AnotherDerivedClass());
            foreach (BaseClass MyClasse in MyClasses)
            {
                MyClasse.A();
            }
            //MySurname
            //Looks like I have no surname
            Console.ReadKey();
        }