当前位置: 首页 > news >正文

崇左网页设计seo工作职位

崇左网页设计,seo工作职位,推广营销策划方案,jsp网站开发系统本文介绍不同类型的方法#xff0c;在代码中的执行顺序问题#xff1a; 构造方法普通方法#xff08;暂用common代替#xff09;、虚方法#xff08;Virtual修饰#xff09;、New方法#xff08;new修饰#xff09;三个优先级相同overide方法#xff08;会替换virtual… 本文介绍不同类型的方法在代码中的执行顺序问题 构造方法普通方法暂用common代替、虚方法Virtual修饰、New方法new修饰三个优先级相同overide方法会替换virtual方法此时virtual方法被隐藏无法再调用到 1. 构造函数方法(constructor)优先级最高new/common/virtual/这三个修饰的方法优先级相同 当父类、子类中的方法都是new/common/virtual/这三类的时候可以理解为实例化对象的类型等号左边的类型是什么就优先调用哪个类中的方法。父类初始化之后无法生成子类的实例化对象。因整个过程没有初始化子类的过程不会生成子类对象。 using ConsoleDeomAlien; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleDeomAlien {public class Product{public Product(){Console.WriteLine(old Constructor-------Product);}public void Intro(){Console.WriteLine(old method--------Intro\n);}}public class NewProduct : Product{public NewProduct(){Console.WriteLine(new Constructor-------NewProduct);}// 这里使用new修饰或不用new都可以。都代表对父类进行重写。// 如果父类注定要被子类重写的父类中可以写个空方法后续子类直接重写即可。public new void Intro() {Console.WriteLine(new method--------Intro\n);}}public class MainMethod{public static void Main(){Product p new Product(); // 初始化和实例对象是相同的此时该class中的方法仅仅是被重写未被覆盖改方法还起作用。// 最终有限调用自己class中的方法p.Intro();NewProduct np new NewProduct();// 子类优先调用该类下面的方法。np.Intro();Product p_np new NewProduct();// 初始化对象是用的子类但是对象是父类类型最终会优先调用父类的方法。p_np.Intro();// !!!不符合逻辑的实例化过程因为父类初始化之后没有调用子类的构造函数无法生成子类的实例对象!!!// NewProduct np_p new Product ();Console.ReadKey();}} } old Constructor-------Product old method--------Introold Constructor-------Product new Constructor-------NewProduct new method--------Introold Constructor-------Product new Constructor-------NewProduct old method--------Intro 2. virtual / override 修饰的父、子类中的方法最终virtual方法会被覆盖且virtual被隐藏无法起作用 using ConsoleDeomAlien; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleDeomAlien {public class Product{public virtual void Intro(){Console.WriteLine(old method--------Intro\n);}}public class NewProduct : Product{public override void Intro(){Console.WriteLine(new method--------Intro\n);}}public class MainMethod{public static void Main(){Product p new Product();p.Intro();NewProduct np new NewProduct();np.Intro();// 虽然实例对象是父类但是调用不到父类的方法了因为被隐藏了。Product p_np new NewProduct(); p_np.Intro();Console.ReadKey();}} } old method--------Intronew method--------Intronew method--------Intro 构造方法的优先级最高父类中的void方法会被子类中的普通common方法或virtual 方法覆盖。virtual common 同等级。当子类中没override的时候new会覆盖virtual / common当override存在时virtual会被替代掉virtual可以父类无法调用到virtual中的方法
http://www.hkea.cn/news/14354448/

相关文章:

  • wordpress所有图片资深seo顾问
  • 报名网站辽宁省建设银行wordpress表情按钮
  • 温州做网站多少钱百度链接提交入口
  • 快速建站公司地址wordpress入站密码
  • 永康高端网站建设html5网站基础
  • 安徽省住房城乡建设部网站福州市住房和城乡建设部网站
  • 北京做网站浩森宇特江苏嘉力电力建设有限公司网站
  • ps做专业网站杭州有什么互联网大厂
  • 网站和网页wordpress做x站主题
  • 泉州住房城乡建设局网站网站新增一个域名备案
  • 唐山彩钢中企动力提供网站建设定制网站建设流程
  • 网站板块设置律师在线咨询
  • 眉山网站建设公司qq空间wordpress
  • 培训教材网站建设wordpress 商务
  • 网站建设 业务员提成网站流量统计系统
  • 建设执业注册中心网站昆明网站建设-中国互联
  • 长沙网站排名方法tq网站建设
  • 网站建设与管理设计wordpress教程文档
  • 新闻类网站开发多久山东建设厅网站首页
  • 建网站空间购买做网站后期要收维护费吗
  • 太原网站排名外包wordpress中view不见了
  • 司法局网站建设网站建设每年需要交多少钱
  • 网站备案实名认证网站后台html编辑器
  • 百度seo网站在线诊断网络广告推广策划书
  • 网站开发英文参考文献win8metro ui风格的wordpress
  • 煤炭建设协会官方网站2023房地产最新消息
  • 做建筑设计网站青岛商城网站开发
  • 蓝海基业做的网站好吗wordpress外贸企业主题
  • 新网站2个月没有收录建立网络专题网站架构
  • 鹤壁集团网站建设班级网站建设图片