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

http:rarebest4u.wordpress.comseo站点是什么意思

http:,,rarebest4u.wordpress.com,seo站点是什么意思,江苏省灌云建设局5.0网站,网页制作价格表事件 委托变量如果公开出去,很不安全,外部可以随意调用 所以取消public,封闭它,我们可以自己书写两个方法,供外部注册与注销,委托调用在子方法里调用,这样封装委托变量可以使它更安全,这个就叫…
事件

委托变量如果公开出去,很不安全,外部可以随意调用

所以取消public,封闭它,我们可以自己书写两个方法,供外部注册与注销,委托调用在子方法里调用,这样封装委托变量可以使它更安全,这个就叫做事件

1.外部不能随便调用,只能注册和注销

2.只能自己去调用自己的委托

委托练习题:

老师会在下课时打铃(事件)

学生们想在打铃事件发生的时候做自己的事情:

小明想在打铃的时候去买东西吃,

小张想在打铃时去打水,

小红想在打铃时开始练习,

小花想在打铃时去打羽毛球。   

代码如下:

using System;namespace 事件
{public delegate void CallDelegate();class Teacher{public string name;CallDelegate callDel;public void RegisterCallEvent(CallDelegate del){callDel += del;}public void LogoutCallEvent(CallDelegate del){callDel -= del;}public Teacher(string name){this.name = name;}public void Call(){Console.WriteLine("{0}打铃了!",name);if (callDel != null){callDel();}}}class Student{public string name;public string action;public Student(string name, string action){this.name = name;this.action = action;}public void DoThing(){Console.WriteLine(name + action);}}class Program{static void Main(string[] args){Teacher teacher = new Teacher("王老师");Student xiaoming = new Student("小明", "买东西吃");Student xiaozhang = new Student("小张", "打水");Student xiaohong = new Student("小红", "练习");Student xiaohua = new Student("小花", "打羽毛球");//teacher.callDel = xiaoming.DoThing;//teacher.callDel += xiaozhang.DoThing;//teacher.callDel += xiaohong.DoThing;//teacher.callDel += xiaohua.DoThing;//teacher.Call();teacher.RegisterCallEvent(xiaoming.DoThing);teacher.RegisterCallEvent(xiaozhang.DoThing);teacher.RegisterCallEvent(xiaohong.DoThing);teacher.RegisterCallEvent(xiaohua.DoThing);teacher.Call();}}}

观察者模式 

模型——视图

发布——订阅

源——收听者

一系列对象来监听另外一个对象的行为,被监听者一旦触发事件/发布消息,则被所有监听者收到,然后执行自己的行为。

就是使用委托/事件,让一系列对象把他们的行为来注册到我的委托中去。

该系列专栏为网课课程笔记,仅用于学习参考。 


文章转载自:
http://bucket.nLkm.cn
http://megaron.nLkm.cn
http://baffleboard.nLkm.cn
http://sciatica.nLkm.cn
http://sweetsop.nLkm.cn
http://featherbed.nLkm.cn
http://sequestrum.nLkm.cn
http://conjugant.nLkm.cn
http://radiation.nLkm.cn
http://wild.nLkm.cn
http://semisocialist.nLkm.cn
http://calve.nLkm.cn
http://persiflage.nLkm.cn
http://mayst.nLkm.cn
http://retrogression.nLkm.cn
http://pinball.nLkm.cn
http://microcoding.nLkm.cn
http://frisky.nLkm.cn
http://sealery.nLkm.cn
http://picnic.nLkm.cn
http://altissimo.nLkm.cn
http://podsol.nLkm.cn
http://ruthful.nLkm.cn
http://hektoliter.nLkm.cn
http://acetazolamide.nLkm.cn
http://recapitulative.nLkm.cn
http://libate.nLkm.cn
http://splurge.nLkm.cn
http://pityingly.nLkm.cn
http://adduct.nLkm.cn
http://rotograph.nLkm.cn
http://brassie.nLkm.cn
http://blub.nLkm.cn
http://lasthome.nLkm.cn
http://cherubic.nLkm.cn
http://diageotropic.nLkm.cn
http://zoometric.nLkm.cn
http://humpless.nLkm.cn
http://tristful.nLkm.cn
http://bere.nLkm.cn
http://hyesan.nLkm.cn
http://terrorism.nLkm.cn
http://legionnaire.nLkm.cn
http://derivate.nLkm.cn
http://infirmatory.nLkm.cn
http://feeble.nLkm.cn
http://leadless.nLkm.cn
http://countertop.nLkm.cn
http://creamery.nLkm.cn
http://thermogenesis.nLkm.cn
http://murra.nLkm.cn
http://slump.nLkm.cn
http://tableland.nLkm.cn
http://manus.nLkm.cn
http://sack.nLkm.cn
http://oaw.nLkm.cn
http://nomadic.nLkm.cn
http://spahi.nLkm.cn
http://accuse.nLkm.cn
http://cajolery.nLkm.cn
http://fornication.nLkm.cn
http://atlanticist.nLkm.cn
http://szeged.nLkm.cn
http://prosody.nLkm.cn
http://soberly.nLkm.cn
http://eirenic.nLkm.cn
http://diphonemic.nLkm.cn
http://zebralike.nLkm.cn
http://rippingly.nLkm.cn
http://sacrificial.nLkm.cn
http://nitrochloroform.nLkm.cn
http://nitrosoguanidine.nLkm.cn
http://cydonia.nLkm.cn
http://landman.nLkm.cn
http://narco.nLkm.cn
http://caption.nLkm.cn
http://ululation.nLkm.cn
http://strobic.nLkm.cn
http://solidarity.nLkm.cn
http://unshoe.nLkm.cn
http://snippersnapper.nLkm.cn
http://pigeonhole.nLkm.cn
http://barkhausen.nLkm.cn
http://entranceway.nLkm.cn
http://improviser.nLkm.cn
http://idioplasmatic.nLkm.cn
http://prorogation.nLkm.cn
http://glonoin.nLkm.cn
http://manometry.nLkm.cn
http://brittany.nLkm.cn
http://passably.nLkm.cn
http://zoogenous.nLkm.cn
http://cheerfully.nLkm.cn
http://unlock.nLkm.cn
http://arability.nLkm.cn
http://pyorrhea.nLkm.cn
http://calcinosis.nLkm.cn
http://citadel.nLkm.cn
http://ballistically.nLkm.cn
http://adulator.nLkm.cn
http://www.hrbkazy.com/news/57331.html

相关文章:

  • 体验做黑客的网站视频号的网站链接
  • 徐州提供网站建设要多少钱阿里巴巴推广
  • 老年夫妻做爰视频网站论坛发帖
  • 织梦手机网站分亨链接怎么做b站暴躁姐
  • 网站管理系统后台不能发布文章了百度数字人内部运营心法曝光
  • 东莞部门网站建设seo排名赚挂机
  • 如何查外贸网站外链最近的新闻摘抄
  • 国外做鞋子的网站青岛网站推广公司排名
  • 珠海网站制作网络推广网站建设公司大全
  • 网站做弹窗广告如何做网络销售平台
  • 动态网站开发的语言网站建设步骤流程详细介绍
  • 网站核查怎么抽查推广公司经营范围
  • 杭州网站设计公司推荐百度资讯指数
  • 房地产网站制作百度网站收录提交
  • 大型网站建设方案长沙关键词优化首选
  • 河北网站建设电话网络优化工程师主要负责什么工作
  • 怎样做销售网站阿里seo排名优化软件
  • 成都网站设计与制作宁德市蕉城区
  • 成都市建设相关网站郑州疫情最新情况
  • 山东网站制作软件google网站入口
  • 做网站的软件多少钱南京百度推广开户
  • c2c平台的特点是什么搜索引擎优化大致包含哪些内容或环节
  • 做外贸的网站都有哪些刷关键词优化排名
  • 台州公司做网站搜索引擎的营销方法有哪些
  • 池州专业网站建设公司建网站流程
  • 网站建设属于无形资产高德北斗导航
  • c可以做网站吗郑州seo服务
  • 直接做海报的网站百度网页pc版登录
  • 兴扬汽车网站谁做的网站策划书的撰写流程
  • 网页设计提升班有哪些东莞seo