Follow @RoyOsherove on Twitter

A simple question about overloading

Given 3 classes: PersonBase, Employee and Manager:

class PersonBase { }

class Employee : PersonBase { }

class Manager : Employee { }


and given the following  methods:


public void Loop()


     PersonBase[] people = new PersonBase[]{

                                 new PersonBase(),

                                 new Employee(),

                                 new Manager()



     foreach (PersonBase pb in people)







 void doSomething(PersonBase p)




 void doSomething(Employee e)




 void doSomething(Manager m)





Why does only the first of the three “doSomething” overloads get called for all the objects in the array?

How could you force those methods to get called?

(Ignore the various class factory solutions out there.)

Some news from the wild

Continuous integration with CruiseControl lessons learned