C# Type comparison
        Posted  
        
            by Sean.C
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sean.C
        
        
        
        Published on 2010-06-14T14:15:01Z
        Indexed on 
            2010/06/14
            14:32 UTC
        
        
        Read the original article
        Hit count: 204
        
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...
© Stack Overflow or respective owner