The extension method IsNot<T>
is a nice way to extend the syntax. Keep in mind
var container = child as IContainer;
if(container != null)
{
// do something w/ contianer
}
performs better than doing something like
if(child is IContainer)
{
var container = child as IContainer;
// do something w/ container
}
In your case, it doesn't matter as you are returning from the method. In other words, be careful to not do both the check for type and then the type conversion immediately after.