【发布时间】:2014-11-03 00:20:16
【问题描述】:
我想在运行时找到泛型 T 的类型并进行比较以检查它是哪个接口。
因此,这适用于在运行时查找 T 的类型:
Type interfaceName = typeof(T); // gives me the specific interface type
但是当我尝试检查它是否等于接口的类型时,我没有得到预期的响应。
Type.GetType("IMyInterface"); //this returns null
如何比较这两者?
【问题讨论】:
-
@TryingToImprove 这不是我想要的。此外,我不想在这部分代码中使用反射。