IsAssignableFrom错过了接口继承

时间:2016-04-10 12:07:05

标签: c# inheritance reflection interface

做这样的事

...
if (!settingsType.IsAssignableFrom(typeof (ISettingsSource)))
            throw new IncorrectCustomizationSourceTypeException(settingsType.Name, nameof(ISettingsSource));
...

实际上,尽管有settingsType is instance of class which derived from a class that implements required interface,但我得到了一个可爱的例外。 正如我所理解的那样,方法检查转换能力类型传入参数,在我的情况下,它应该工作。

检查这种情况的正确方法是什么?

提前谢谢。

0 个答案:

没有答案