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(); }
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(); } //DerivedClass //MySurname //AnotherDerivedClass //Looks like I have no surname Console.ReadKey(); }