Here is what I want:

Code:
interface IEvent
{
  ...
}

class EventType1 : IEvent
{
  ...
}

class EventListenter
{
  public void HandleEvent(IEvent evt)
  {
     ...
  }

  public void HandleEvent(EventType1 evt)
  {
     ...
  }
}

class EventManager
{
   List<IEvent> events;
   EventListener listener;

   public void ProcessEvents
   {
      foreach(IEvent event in events)
      {
         listener.HandleEvent(event);
      }
   }
}
So basically I want the EventManager class to call the correct version of the HandleEvent function based on the type of event it is. However it does not. It seems that because the events list contains IEvent objects, it just always calls that version of the HandleEvent function. Even if the specific event is an EventType1, it still calls the more general IEvent version of the function.

I could but in a big if statement to get it to call the right version but I was hoping for something more elegant. Am I missing something?

Thanks.