【发布时间】:2011-03-15 22:07:31
【问题描述】:
我有一个像下面这样的课程。 GetInterfaces() 说
如果当前Type代表一个类型 a 定义中的参数 泛型类型或泛型方法,this 方法搜索接口 约束和任何接口 从类或接口继承 约束。
我是否有可能没有得到任何继承的接口?当我在 ABC 上使用 GetInterfaces 时,我只想看到 DEF,而不是 DEF 和 GHI。
interface DEF : GHI {...}
class ABC : DEF {...}
【问题讨论】:
-
自从我
m only on my iPad I cant 测试代码或查找所有方法,但这里s a thought. Could you find all the interfaces your type implements (including inherites ones), then move on to the base type of your type, find all the interfaces *that* type implements, and subtract those from the first set? I would think you would be left with what ABC itself added of interfaces. If anyone wants to "steal" this comment and type up a real answer of it, please do, it wont 等到明天,直到我回到我的电脑。 -
GetInterfaces() 是 Type 类的方法。
-
啊,对不起,你的“基础类型”是接口,那我就不知道了。
-
@Lasse:我对这个问题的理解不同;我认为 OP 只对接口层次结构感兴趣。
标签: c# reflection