【发布时间】:2009-02-11 15:48:38
【问题描述】:
我不确定这里的确切术语。基本上,如果我有这样的模型:
class Student : IDoSchool {}
class Freshman : Student {}
interface IDoSchool {}
什么代码会告诉我 Freshman 不直接实现任何接口而 Student 直接实现 IDoSchool?
换句话说(忽略不好的术语)我想要这样的东西:
typeof(Freshman).GetInterfaces(BindingFlags.DeclaredOnly); // nothing
typeof(Student).GetInterfaces(BindingFlags.DeclaredOnly); // IDoSchool
想法?
【问题讨论】:
-
在你的例子中,新生应该是学生的子类吗?
标签: c# .net reflection