In c#, the parent class calls the properties and methods of the subclass

巴扎黑
Release: 2016-12-19 15:43:33
Original
4207 people have browsed it

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";

}

Related labels:
c#
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!