Maybe the need to do this is a 'design smell' but thinking about another question, I was wondering what the cleanest way to implement the inverse of this:
foreach(ISomethingable somethingableClass in collectionOfRelatedObjects)
{
somethingableClass.DoSomething();
}
i.e. How to get/iterate through all the objects that don't implement a particular interface?
Presumably you'd need to start by upcasting to the highest level:
foreach(ParentType parentType in collectionOfRelatedObjects)
{
// TODO: iterate through everything which *doesn't* implement ISomethingable
}
Answer by solving the TODO: in the cleanest/simplest and/or most efficient way