【问题标题】:Finding all Interface that a class implements查找类实现的所有接口
【发布时间】:2014-04-05 20:54:15
【问题描述】:

谁能告诉我如何找到一个类使用 C# 反射实现的所有接口?

查找所有实现特定接口的类

if(type.getInterface(typeof(IAuto)) != null)
{
   console.writeline(type.name.tostring());
}

【问题讨论】:

标签: c# reflection


【解决方案1】:
var interfaces = typeof(Classname).GetInterfaces();

【讨论】:

  • @Scoregraphic:我不确定你的编辑。他想要类的所有接口,而不是 IAuto 继承的所有接口。
  • 切换回我原来的解决方案,因为我认为它更适合这个问题
  • 同意,我的错!类型未知。
猜你喜欢
  • 2015-04-07
  • 2012-04-16
  • 1970-01-01
  • 2010-12-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-16
  • 2023-03-03
相关资源
最近更新 更多