Home > Article > Backend Development > In c#, the parent class calls the properties and methods of the subclass
We are used to thinking that the subclass is invisible to the parent class, or the parent class does not know the existence of the subclass, so the parent class cannot call the methods and attributes of the subclass. In the following way, the parent class can be implemented The function of calling subclass attributes and methods is welcome. . .
public class WeChatBaseController //Parent class
{
public WeChatBaseController()
{
}
public string MyUserList { get; set; }
var result = WeChat.GetPage(MyUserList)
}
public class WeChatWorkGroupController : WeChatBaseController //Subclass
{
Public WeChatBaseController BaseController;
Public WeChatWorkGroupController()
= "aaaaaaaaaaaaaa";
}