C# Type comparison
- by Sean.C
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:
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.
Stange thing is i do the exact same thing just on an external assembly in the same application and it works as expected...