简体   繁体   中英

How to invoke, access public members of base class in derived class

I have 3 concrete classes named ClassA (that is built-in System.Web.UI.Page class), ClassB, and ClassC (see codes below). ClassC is a dervived class of ClassB that is in turn is a derived class of ClassA. ClassB has its own members. My question is how can ClassC invoke or access members (public properties, public methods) of ClassB? How are the scopes of classes solved in source codes of ClassC to avoid ambiguity? Thanks in advance.

Some codes:

// ClassA = System.Web.UI.Page
public class System.Web.UI.Page {
    // built-in class
}

public class ClassB : System.Web.UI.Page {
   // some own properties
   public bool IsUserLoginNameVisible { get; set; }

   // some own methods
   public void GetLoginUsers()
   {
   }
}

public class ClassC : ClassB {
   public int NumberOfLoginUsers()
   {
       // how can I invoke method "GetLoginUsers()" from ClassB in here?
       // base.GetLoginUsers() ???
   }

   public bool CheckToSeeUserLoginNameVisible()
   {
      // how can I access property "IsUserLoginNameVisible" from ClassB in here?
      // base.IsUserLoginNameVisible ???
   }
}

Derived classes inherit all accessible members from their base class.

You can call them just like any other instance method.

The base keyword will force the call to resolve to the (immediate) base class' definition, even if your class shadows it, or your or derived class overrides it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM