[英]C# Type comparison
This has me pooped, is there any reason the following: 这使我大便,是否有以下任何原因:
public abstract class aExtension
{
public abstract bool LoadExtension(Constants c); // method required in inherit
public abstract string AppliesToModule // property required in inherit
{
get;
}
public abstract string ExtensionName // property required in inherit
{
get;
}
public abstract string ExtensionDescription // property required in inherit
{
get;
}
}
public class UK : aExtension
{
public override bool LoadExtension(Constants c)
{
return true;
}
public override string AppliesToModule
{
get { return "string"; }
}
public override string ExtensionName
{
get { return "string"; }
}
public override string ExtensionDescription
{
get { return "string"; }
}
}
would return false for the following expressions: 对于以下表达式,将返回false:
bool a = t.IsAssignableFrom(aExtension));
bool b = t.BaseType.IsAssignableFrom(aExtension));
bool c = typeof(aExtension).IsAssignableFrom(t);
bool d = typeof(aExtension).IsAssignableFrom(t.BaseType);
bool e = typeof(aExtension).IsSubclassOf(t);
bool f = typeof(aExtension).IsSubclassOf(t.BaseType);
bool g = t.IsSubclassOf(typeof(aExtension));
bool h = t.BaseType.IsSubclassOf(typeof(LBT.AdMeter.aExtension));
bool i = t.BaseType.Equals(typeof(aExtension));
bool j = typeof(aExtension).Equals(t.BaseType);
T is the reflected Type from the calss UK. T是英国calss的反射类型。
Stange thing is i do the exact same thing just on an external assembly in the same application and it works as expected... Stange的事情是我只是在同一应用程序的外部程序集上做完全相同的事情,并且按预期工作...
UK
可能会从该程序集的不同版本继承aExtension
。
Do you have a copy of the same assembly around? 您周围是否有相同程序集的副本? If the same assembly is loaded from a different location, the types are not compatible.
如果从不同位置加载相同的装配件,则类型不兼容。
Are you loading assemblies by reflection only somewhere? 您是否仅通过反射加载装配件? I think I had issues with that.
我认为我对此有疑问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.