Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Interface inheritance
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Titre:
Interface inheritance
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01191305
Message ID:
01191305
Vues:
63
Hi All, quick question on Interface inheritance, if a base class inherits from an Interface, do any subclasses automatically inherit from the Interface ?, the reason I ask is, my class hierarchy is as shown below but I receive compiler warnings about my subclasses hiding methods defined in the base class
 public interface ICMSTabPage
 {
    int LoadPageData(object sender, CMSMasterEventArgs e);
    void ChangeDisplay(object sender, CMSMasterEventArgs e);
    void ClearPageData(object sender, CMSMasterEventArgs e);
 }

/* Implement the interface methods. So far so good.*/
public abstract class PJKTabCMS : BCCI.Controls.PJKBaseTabPage,ICMSTabPage
{
    public int LoadPageData(object sender, CMSMasterEventArgs e)
    {
        return 0;
    }

    public void ChangeDisplay(object sender, CMSMasterEventArgs e)
    {
    }

    public void ClearPageData(object sender, CMSMasterEventArgs e)
    {
    }
}

/* I then subclass PJKTabCMS

and receive a compiler warning


public class PJKTabCMSPaymentDetails : PJKTabCMS
{
 
    public int LoadPageData(object sender, CMSMasterEventArgs e)
    {
          
    }

    public void ChangeDisplay(object sender, CMSMasterEventArgs e)
    {
         
    }

    public void ClearPageData(object sender, CMSMasterEventArgs e)
    {
    
    }
    }
}
/* Compiler warning text

Warning 1 'BCCI.CustomerManagement.CMSTabPages.PJKTabCMSPaymentDetails.LoadPageData(object, BCCI.CustomerManagement.CMSEventArgs.CMSMasterEventArgs)' hides inherited member 'BCCI.CustomerManagement.CMSTabPages.PJKTabCMS.LoadPageData(object, BCCI.CustomerManagement.CMSEventArgs.CMSMasterEventArgs)'. Use the new keyword if hiding was intended. J:\HOME\PJK\PROJECTS\CMS\CMSTabPages\CMSTabPages.cs 116 20 CMSTabPages


If I mark the interface methods in my base class as virtual and override them in the subclasses the compiler would probably stop complaining, but then, I might as well use abstract classes and cut out the interface - am I missing somehing here ?
Regards,
Peter J. Kane



Pete
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform