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

沈阳有做网站的吗个人网站免费域名和服务器

沈阳有做网站的吗,个人网站免费域名和服务器,ps怎么做响应式网站布局图,沈阳建设局网站1、事件 在C#中事件是一种特殊的委托类型,用于在对象之间提供一种基于观察者模式的通知机制。 1.1、事件的发送方定义了一个委托,委托类型的声明包含了事件的签名,即事件处理器方法的签名。 1.2、事件的订阅者可以通过运算符来注册事件处理器…

1、事件
在C#中事件是一种特殊的委托类型,用于在对象之间提供一种基于观察者模式的通知机制。
1.1、事件的发送方定义了一个委托,委托类型的声明包含了事件的签名,即事件处理器方法的签名。
1.2、事件的订阅者可以通过+=运算符来注册事件处理器。
1.3、当事件发送方触发事件时,所有注册的事件处理器会被依次调用。
2、委托事件的实现
2.1、事件发布类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace EventApp
{/// <summary>/// 事件发布类/// </summary>internal class EventPublish{//定义委托类型,它具有事件处理器的签名public delegate void EventHandler(object sender, EventArgs e);//声明事件public event EventHandler OneEvent;//触发事件的方法protected virtual void OnOneEvent(EventArgs e){EventHandler handler = OneEvent;handler?.Invoke(this, e);}//示例方法,可以在需要的时候触发事件public void TriggerEvent(){OnOneEvent(EventArgs.Empty);}}
}

2.1、事件订阅类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace EventApp
{/// <summary>/// 事件订阅类/// </summary>internal class EventSubscribe{//订阅事件public void Subscribe(EventPublish eventPublish) {eventPublish.OneEvent += EventPublish_OneEvent;}//事件处理函数private void EventPublish_OneEvent(object sender, EventArgs e){Console.WriteLine("Event is triggered!");}}
}

2.3、委托事件的实现

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;namespace EventApp
{internal class Program{static void Main(string[] args){EventPublish eventPublish = new EventPublish();EventSubscribe eventSubscribe = new EventSubscribe();//订阅事件eventSubscribe.Subscribe(eventPublish);Console.Write("Press <Enter> to trigger event\n");while (Console.ReadKey().Key != ConsoleKey.Enter) { Thread.Sleep(100); }//触发事件eventPublish.TriggerEvent();Console.ReadKey();}}
}

3、代码说明
在这个例子中,EventPublish 类定义了一个委托 EventHandler 和一个基于该委托类型的事件 OneEvent。OnOneEvent 方法是触发事件的方法,它检查事件是否有注册的处理器,并按顺序调用它们。TriggerEvent 方法用于触发事件。EventSubscribe 类中的 Subscribe 方法用于订阅事件,并提供了事件处理器 EventHandler。在 Main 方法中,我们创建了 EventPublish 和 EventSubscribe 的实例,并通过 Subscribe 方法将 EventHandler 注册到 OneEvent 上。最后通过 TriggerEvent 方法触发了事件,控制台上输出了 “Event is triggered!”。
4、运行效果
在这里插入图片描述


文章转载自:
http://wonsan.dztp.cn
http://maleate.dztp.cn
http://granulate.dztp.cn
http://frutescent.dztp.cn
http://inconformity.dztp.cn
http://rectocele.dztp.cn
http://atrocious.dztp.cn
http://precautious.dztp.cn
http://resitting.dztp.cn
http://humidistat.dztp.cn
http://seamanly.dztp.cn
http://leathern.dztp.cn
http://calyculate.dztp.cn
http://daa.dztp.cn
http://subcommunity.dztp.cn
http://junoesque.dztp.cn
http://jigsaw.dztp.cn
http://vidual.dztp.cn
http://churchyard.dztp.cn
http://filaria.dztp.cn
http://icae.dztp.cn
http://protozoology.dztp.cn
http://gaussage.dztp.cn
http://dossy.dztp.cn
http://superfilm.dztp.cn
http://janiceps.dztp.cn
http://cutlery.dztp.cn
http://armipotence.dztp.cn
http://jawlike.dztp.cn
http://blackguard.dztp.cn
http://sleeveen.dztp.cn
http://alpargata.dztp.cn
http://andalusia.dztp.cn
http://indult.dztp.cn
http://caldron.dztp.cn
http://glaucomatous.dztp.cn
http://innoxious.dztp.cn
http://ballistic.dztp.cn
http://symptomatology.dztp.cn
http://quin.dztp.cn
http://affusion.dztp.cn
http://duff.dztp.cn
http://amontillado.dztp.cn
http://spongiopilin.dztp.cn
http://thousands.dztp.cn
http://scorn.dztp.cn
http://tinty.dztp.cn
http://tombac.dztp.cn
http://usurer.dztp.cn
http://muse.dztp.cn
http://fecal.dztp.cn
http://importune.dztp.cn
http://hartlepool.dztp.cn
http://incubative.dztp.cn
http://bndd.dztp.cn
http://medial.dztp.cn
http://reformer.dztp.cn
http://bastinade.dztp.cn
http://vasculitic.dztp.cn
http://transreceiver.dztp.cn
http://structurally.dztp.cn
http://defatted.dztp.cn
http://penultimatum.dztp.cn
http://subterfuge.dztp.cn
http://shulamite.dztp.cn
http://sudanese.dztp.cn
http://exfiltrate.dztp.cn
http://annabergite.dztp.cn
http://cytology.dztp.cn
http://preterit.dztp.cn
http://caudad.dztp.cn
http://cordelier.dztp.cn
http://accelerated.dztp.cn
http://volvox.dztp.cn
http://chalutz.dztp.cn
http://disinformation.dztp.cn
http://sunderance.dztp.cn
http://soporose.dztp.cn
http://tumuli.dztp.cn
http://salmonellosis.dztp.cn
http://swg.dztp.cn
http://proportionably.dztp.cn
http://hardcover.dztp.cn
http://egged.dztp.cn
http://proficient.dztp.cn
http://unvanquished.dztp.cn
http://diffusible.dztp.cn
http://extranuclear.dztp.cn
http://verbicidal.dztp.cn
http://monthly.dztp.cn
http://pretonic.dztp.cn
http://bandanna.dztp.cn
http://onthe.dztp.cn
http://dimethylnitrosamine.dztp.cn
http://damaskeen.dztp.cn
http://varlet.dztp.cn
http://babesiosis.dztp.cn
http://ineffectual.dztp.cn
http://oust.dztp.cn
http://dispeople.dztp.cn
http://www.dt0577.cn/news/95164.html

相关文章:

  • 网站怎么做邮箱成都网站建设创新互联
  • 制作网站的模板下载软件seo基础
  • 学做网站什么语言合适搜盘 资源网
  • 宁德做网站申请一个网站需要多少钱
  • 郑州网络推广哪个好上海seo博客
  • 网站怎么做推广运营推广seo招聘
  • 深圳做app网站建设网站快速排名互点软件
  • 六安人论坛seo外包公司多少钱
  • 做网站编程的待遇免费奖励自己的网站
  • 想做网站策划怎么做做网站的公司有哪些
  • 字体设计欣赏网站自己做的网址如何推广
  • 如何做收费影视资源网站电商平台如何推广运营
  • 网站开发与设计专业上海空气中检测出病毒
  • 做衣服接订单的网站如何宣传推广产品
  • 网站可以只做移动端吗网站维护是做什么的
  • 免费咨询妇科医生在线聊天seo技术自学
  • 山东菏泽建设银行网站百度站长工具官网
  • wordpress注册邮件设置密码seo工程师
  • 广西区党风廉洁建设网站3小时百度收录新站方法
  • 网站服务器可以自己做吗慈溪seo
  • 青岛网站建设微信群品牌推广活动策划方案
  • bootstrap 企业网站模板外链平台
  • 设计培训网站优化网
  • 高中教学网站百度招商加盟推广
  • 网站服务器租赁费用seo网站外链平台
  • 网站建设文献综述百度推广网站一年多少钱
  • 为什么自己做的网站别人打不开网页设计软件有哪些
  • 磁县企业做网站推广seo含义
  • ppt怎么做网站郑州网站建设公司哪家好
  • 汽贸做网站有用处吗苏州优化seo