No, is
only works for checking the type of an object, not for a given Type
. You want Type.IsAssignableFrom
:
if (attr != null && typeof(IInterface).IsAssignableFrom(type))
Note the order here. I find that I almost always use typeof(...)
as the target of the call. Basically for it to return true, the target has to be the “parent” type and the argument has to be the “child” type.