How to check that type is inherited from some interface c#

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)