How do I call different methods for different class-types in a generic message-receiver?-Collection of common programming errors
It is possible to do what you’re suggesting, though it’s not very DRY, and I think the other suggestions here are more appropriate. Still, in the interest of completeness, here’s an approach close to what you were originally looking for:
void ReceiveMessage( IMessage message ) {
if( message as DummyMessage != null ) HandleMessage( message as DummyMessage );
else if( message as SillyMessage != null ) HandleMessage( message as SillyMessage );
// etc
}