【发布时间】:2026-02-06 08:05:03
【问题描述】:
我有Interface 和Generic Type
public interface IWork<T>
{
void Work(MySession session, T json);
}
在尝试此代码时,我试图找到所有实现 Interface 的所有泛型类型的 Classes
var type = typeof(IWork<>);
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => type.IsAssignableFrom(p));
它自己返回Interface。
【问题讨论】:
标签: c# reflection typeof