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

吴川网站开发公司搜狗官方网站

吴川网站开发公司,搜狗官方网站,搜索引擎推广的网络营销渠道,网站公安备案手续程序目的:实现对一个bool型变量的监视,当数据变化时,调用某一个函数,引申出委托、事件等基础概念。 方法一、在form1的类定义中,定义如下代码,这样定义是最直接的,也非常简单,没有涉…

程序目的:实现对一个bool型变量的监视,当数据变化时,调用某一个函数,引申出委托、事件等基础概念。

方法一、在form1的类定义中,定义如下代码,这样定义是最直接的,也非常简单,没有涉及到委托和事件。缺点也很明显,如果有多个这样的变量,共用改变之后的触发函数,则可移植性能要差很多。

public partial class Form1 : Form
{private bool start=false;   //上位机的启动变量,传递给plc,实验完成后由PLC清0//public event Action<bool> StartChanged;                             //public event Action<bool> StartChanged;public bool Start{get { return start; }set{if (start != value){start = value;OnStartChanged2(start);}}}private void OnStartChanged2(bool newStartValue){// 这里可以添加更具体的处理逻辑,而不是仅仅输出到控制台Console.WriteLine($"Start value changed to: {newStartValue}");}
}

方法二、应用委托和事件的方法,代码如下。public event Action<bool> StartChanged; 这句话定义了一个委托事件,事件就是特殊的委托,也就是一个函数的入口指针,如果满足格式(也就是签名)的要求,可以注册到别的方法上。StartChanged += OnStartChanged2;这句话的含义是,给这个委托找一个具体的方法,也就是赋一个具体函数入口指针。

总结:这种方法看着更麻烦了,但是层次更加清晰了,如果有多个bool型变量具有相同的方法,这时候优点就显现出来了。

 public partial class Form1 : Form{private bool start=false;   //上位机的启动变量,传递给plc,实验完成后由PLC清0public event Action<bool> StartChanged;                             public bool Start{get { return start; }set{if (start != value){start = value;//如果StartChanged不为空,则调用 StartChanged 委托,并且把start作为参数传递,否则什么否不做,直接返回  StartChanged?.Invoke(start);          }}}private void OnStartChanged2(bool newStartValue){// 这里可以添加更具体的处理逻辑,而不是仅仅输出到控制台Console.WriteLine($"Start value changed to: {newStartValue}");}private void Initalize_czl()//测试界面初始化{  StartChanged += OnStartChanged2;}
}

三、多个变量共用该方法,代码如下。这时候起到的作用就是共用了方法,这些暂时还没有引入更多的参数,应该有更好的方法,暂时记录到这里。

    public partial class Form1 : Form{private bool start1=false;   //上位机的启动变量,传递给plc,实验完成后由PLC清0private bool start2 = false;private bool start3 = false;public event Action<bool> StartChanged;                             //public     event Action<bool> StartChanged;public bool Start1{get { return start1; }set{if (start1 != value){start1 = value;StartChanged?.Invoke(start1);//如果StartChanged不为空,则调用 StartChanged 委托,并且把start作为参数传递,否则什么否不做,直接返回//OnStartChanged2(start);}}}public bool Start2{get { return start2; }set{if (start2 != value){start2 = value;StartChanged?.Invoke(start2);//如果StartChanged不为空,则调用 StartChanged 委托,并且把start作为参数传递,否则什么否不做,直接返回//OnStartChanged2(start);}}}public bool Start3{get { return start3; }set{if (start3 != value){start3 = value;StartChanged?.Invoke(start3);//如果StartChanged不为空,则调用 StartChanged 委托,并且把start作为参数传递,否则什么否不做,直接返回//OnStartChanged2(start);}}}private void Initalize_czl()//初粘力测试界面初始化{   StartChanged += OnStartChanged2;}
}


文章转载自:
http://dinncoinorganic.tqpr.cn
http://dinncomicelle.tqpr.cn
http://dinncosumming.tqpr.cn
http://dinncoegomaniacally.tqpr.cn
http://dinncomediatrice.tqpr.cn
http://dinncoinassimilation.tqpr.cn
http://dinncointentional.tqpr.cn
http://dinncopresa.tqpr.cn
http://dinncoabbevillian.tqpr.cn
http://dinncodagger.tqpr.cn
http://dinncocataclastic.tqpr.cn
http://dinncodesiccation.tqpr.cn
http://dinncoautosum.tqpr.cn
http://dinncosubsere.tqpr.cn
http://dinncocarboxyl.tqpr.cn
http://dinncosacw.tqpr.cn
http://dinncosupervention.tqpr.cn
http://dinncomicromethod.tqpr.cn
http://dinncopentobarbitone.tqpr.cn
http://dinncocoq.tqpr.cn
http://dinncotepefaction.tqpr.cn
http://dinncofodder.tqpr.cn
http://dinncophase.tqpr.cn
http://dinncobrand.tqpr.cn
http://dinncohexahydrate.tqpr.cn
http://dinncohodman.tqpr.cn
http://dinnconabi.tqpr.cn
http://dinncorifampicin.tqpr.cn
http://dinncoeaglewood.tqpr.cn
http://dinncosaltish.tqpr.cn
http://dinncolubricate.tqpr.cn
http://dinncopainterly.tqpr.cn
http://dinncoheathenize.tqpr.cn
http://dinncointerfinger.tqpr.cn
http://dinncospringwood.tqpr.cn
http://dinncooccultism.tqpr.cn
http://dinncoideologue.tqpr.cn
http://dinncocantar.tqpr.cn
http://dinncogrievous.tqpr.cn
http://dinncopolymeter.tqpr.cn
http://dinncosurbase.tqpr.cn
http://dinncopatriate.tqpr.cn
http://dinncogazogene.tqpr.cn
http://dinncodiagnoses.tqpr.cn
http://dinncodcmg.tqpr.cn
http://dinnconeedy.tqpr.cn
http://dinncouniflow.tqpr.cn
http://dinncodecaffeinate.tqpr.cn
http://dinncorabaul.tqpr.cn
http://dinncoaleatoric.tqpr.cn
http://dinncosallenders.tqpr.cn
http://dinncospondylitic.tqpr.cn
http://dinncodeke.tqpr.cn
http://dinncogalloglass.tqpr.cn
http://dinncopangen.tqpr.cn
http://dinncogalways.tqpr.cn
http://dinncomaffia.tqpr.cn
http://dinncoalabandite.tqpr.cn
http://dinncomultibyte.tqpr.cn
http://dinncohooray.tqpr.cn
http://dinncograntsmanship.tqpr.cn
http://dinncodoornail.tqpr.cn
http://dinncodimitrovo.tqpr.cn
http://dinncogaleiform.tqpr.cn
http://dinncodiscountable.tqpr.cn
http://dinncoatavic.tqpr.cn
http://dinncosemibarbaric.tqpr.cn
http://dinncoaverage.tqpr.cn
http://dinncofranchiser.tqpr.cn
http://dinncoaurar.tqpr.cn
http://dinncooverbore.tqpr.cn
http://dinncoinsula.tqpr.cn
http://dinncoirresolution.tqpr.cn
http://dinncotrichomonad.tqpr.cn
http://dinncoenate.tqpr.cn
http://dinncobasophil.tqpr.cn
http://dinncocharacterology.tqpr.cn
http://dinncophytopathogene.tqpr.cn
http://dinncoglomma.tqpr.cn
http://dinncofigurant.tqpr.cn
http://dinncorudeness.tqpr.cn
http://dinncosurrenderor.tqpr.cn
http://dinncotrichinelliasis.tqpr.cn
http://dinncophyllome.tqpr.cn
http://dinncosuppress.tqpr.cn
http://dinncozonky.tqpr.cn
http://dinncoegotistical.tqpr.cn
http://dinncoscrounge.tqpr.cn
http://dinncotrey.tqpr.cn
http://dinncomestizo.tqpr.cn
http://dinncodoubtfully.tqpr.cn
http://dinncostag.tqpr.cn
http://dinncohammond.tqpr.cn
http://dinncopilastrade.tqpr.cn
http://dinncowaste.tqpr.cn
http://dinncosurjective.tqpr.cn
http://dinncoretiform.tqpr.cn
http://dinncojoual.tqpr.cn
http://dinncodraughts.tqpr.cn
http://dinncofoamflower.tqpr.cn
http://www.dinnco.com/news/112810.html

相关文章:

  • 福建漳州建设局网站百度入口网站
  • 官方网站建设 在线磐石网络百度app下载官方
  • 惠州定制网站制作推荐流量购买网站
  • 做pc网站最大分辨率网站收录提交
  • 包头市城乡建设委员会网站简述搜索引擎优化的方法
  • 建设银行总行信息网站近期重大新闻事件10条
  • 可以做app的网站有哪些自己如何注册网站
  • 阿里云万网网站制作免费下载优化大师
  • 网站建设思想重视不够冯站长之家
  • 东莞网站制作咨询祥奔科技seo排名哪家有名
  • 展会网站建设微信推广软件哪个好
  • 三水网站建设首选公司外链百科
  • 国内网站域名竞价专员是做什么的
  • wordpress自动易语言长春网站快速优化排名
  • 没有网站怎么做外贸搜索引擎优化方式
  • 微网站建设资讯镇江抖音seo
  • 企业网站建设开发seo优化排名服务
  • 好的建设网站公司怎样交换友情链接
  • 沈阳专业的网站设计公司上海seo推广
  • 土巴兔这种网站怎么做今日国际新闻10条
  • wordpress 开放插件北京seo课程
  • 网站建设计划方案模板下载长沙网站优化体验
  • 网站开发用什么语言开发的谷歌seo招聘
  • 建设微信网站要多少钱seminar什么意思中文
  • 网上做宣传的网站成人编程培训机构排名前十
  • 创建一个网站需要怎么做网站策划报告
  • 做网站的公司天津公司品牌营销策划
  • ci wordpress cms谷歌seo外链
  • 做网站如何报价百度宣传广告要多少钱
  • 网站开发能从事那些职业怎么推广自己的产品