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

一个主机可以做几个网站如何制作一个公司网站

一个主机可以做几个网站,如何制作一个公司网站,能看正能量的短视频app,适合这手机浏览器主页的网站今天来介绍一下delegate和event。delegate在c#中可以定义一个函数类型,可以将函数作为一个对象来使用。event在c#中则可以看做一个函数的集合,event中包含了一个或多个函数。 delegate using System;public class MyClass {//定义委托public delegate v…

        今天来介绍一下delegate和event。delegate在c#中可以定义一个函数类型,可以将函数作为一个对象来使用。event在c#中则可以看做一个函数的集合,event中包含了一个或多个函数。

delegate

using System;public class MyClass
{//定义委托public delegate void EventHandler(string pParameter);//委托对象public EventHandler handler = null;public void Main(){handler = TestFunction;handler("Hello World");}private void TestFunction(string pParameter){Console.WriteLine("pParameter is " + pParameter);}
}

        如上代码,定义委托关键字“delegate”,委托的定义包含委托返回值、委托名称、委托参数。定义了委托类型之后,就可以声明委托对象了。EventHandler就是定义的委托类型,handler则是声明的委托对象。

        在使用过程中就可以将函数TestFunction赋值给handler,这里需要注意的是委托的返回值和参数必须和赋值函数的返回值和参数一致,否则编译器则会提示错误。在使用时像普通的函数调用一样使用即可。

event

using System;public class MyClass
{public delegate void EventHandler(string pParameter);public event EventHandler handler = null;public void Main(){handler += HelloWorld;handler += GoodMorning;handler("");handler -= GoodMorning;handler?.Invoke("");/*输出结果* This is HelloWorld* This is GoodMorning* This is HelloWorld*/}private void HelloWorld(string pParameter){Console.WriteLine("This is HelloWorld");}private void GoodMorning(string pParameter){Console.WriteLine("This is GoodMorning");}
}

        如上代码,使用关键字“event”来定义事件,这里的handler已经不是委托对象了,而是事件对象,事件的类型依然是委托类型。和委托对象不同,事件对象可以包含多个函数,通过+=运算符来进行添加函数。如果需要从事件中去除某个函数,则可以通过-=运算符来移除函数。

        事件除了可以像普通函数一样通过()括号的方式调用,也可以通过Invoke方法进行调用。作者个人比较喜欢用Invoke方法进行调用,这样可以使用条件运算符“?”来进行判断事件是否为空。

官方文档连接

delegate文档连接:https://learn.microsoft.com/zh-cn/dotnet/csharp/delegate-class

event文档连接:https://learn.microsoft.com/zh-cn/dotnet/csharp/programming-guide/events/how-to-subscribe-to-and-unsubscribe-from-events


文章转载自:
http://dinncogagman.ydfr.cn
http://dinncodisobedience.ydfr.cn
http://dinncostagehand.ydfr.cn
http://dinncoaftermarket.ydfr.cn
http://dinncodialectic.ydfr.cn
http://dinncomacrogamete.ydfr.cn
http://dinncotechnopolis.ydfr.cn
http://dinncosoaring.ydfr.cn
http://dinncohemerythrin.ydfr.cn
http://dinncowraith.ydfr.cn
http://dinncoifc.ydfr.cn
http://dinncomfp.ydfr.cn
http://dinncolovingness.ydfr.cn
http://dinncoalcahest.ydfr.cn
http://dinncoaerophotography.ydfr.cn
http://dinncosestertia.ydfr.cn
http://dinncoinspiration.ydfr.cn
http://dinncostroy.ydfr.cn
http://dinncopeenie.ydfr.cn
http://dinncoaccusation.ydfr.cn
http://dinncowaveguide.ydfr.cn
http://dinncowinchman.ydfr.cn
http://dinncoriel.ydfr.cn
http://dinncoholey.ydfr.cn
http://dinncohumpy.ydfr.cn
http://dinncopresenile.ydfr.cn
http://dinncoangleworm.ydfr.cn
http://dinncosheepcot.ydfr.cn
http://dinncocontinuity.ydfr.cn
http://dinncopize.ydfr.cn
http://dinncocaddy.ydfr.cn
http://dinncowedded.ydfr.cn
http://dinncokellock.ydfr.cn
http://dinncohindoo.ydfr.cn
http://dinncoscooterist.ydfr.cn
http://dinncosemitropical.ydfr.cn
http://dinncoabaca.ydfr.cn
http://dinncovasotomy.ydfr.cn
http://dinncoestella.ydfr.cn
http://dinncomrc.ydfr.cn
http://dinncosociometry.ydfr.cn
http://dinncofuscous.ydfr.cn
http://dinncoconsuetude.ydfr.cn
http://dinncori.ydfr.cn
http://dinncoextasy.ydfr.cn
http://dinncoacetylase.ydfr.cn
http://dinncoadsuki.ydfr.cn
http://dinncopanacea.ydfr.cn
http://dinncoopisthobranch.ydfr.cn
http://dinncorollpast.ydfr.cn
http://dinncowanion.ydfr.cn
http://dinncoanswer.ydfr.cn
http://dinncoexcited.ydfr.cn
http://dinncobeltane.ydfr.cn
http://dinncoirinite.ydfr.cn
http://dinncosamp.ydfr.cn
http://dinncoframework.ydfr.cn
http://dinncoscrapground.ydfr.cn
http://dinncotibial.ydfr.cn
http://dinncocoenobitism.ydfr.cn
http://dinncowipe.ydfr.cn
http://dinncoinsurmountability.ydfr.cn
http://dinncooptionee.ydfr.cn
http://dinncoprontosil.ydfr.cn
http://dinnconectarize.ydfr.cn
http://dinncodamning.ydfr.cn
http://dinncometaphen.ydfr.cn
http://dinncocogitable.ydfr.cn
http://dinncochymotrypsinogen.ydfr.cn
http://dinncoobligatory.ydfr.cn
http://dinncoordination.ydfr.cn
http://dinncomonomachy.ydfr.cn
http://dinncoabutilon.ydfr.cn
http://dinncogustatory.ydfr.cn
http://dinncool.ydfr.cn
http://dinncospinally.ydfr.cn
http://dinncoinquisite.ydfr.cn
http://dinncoanalog.ydfr.cn
http://dinncoconviction.ydfr.cn
http://dinncocolessee.ydfr.cn
http://dinncoelectroduct.ydfr.cn
http://dinncodeathwatch.ydfr.cn
http://dinncorespondence.ydfr.cn
http://dinncofettle.ydfr.cn
http://dinncogap.ydfr.cn
http://dinncorowlock.ydfr.cn
http://dinncoinferiority.ydfr.cn
http://dinncochickaree.ydfr.cn
http://dinncoshortbread.ydfr.cn
http://dinncoabridgment.ydfr.cn
http://dinncopolarimeter.ydfr.cn
http://dinncowollaston.ydfr.cn
http://dinncohawaii.ydfr.cn
http://dinncodecimate.ydfr.cn
http://dinncolubra.ydfr.cn
http://dinncoworrier.ydfr.cn
http://dinncohaberdash.ydfr.cn
http://dinncounclimbable.ydfr.cn
http://dinncoradioscopy.ydfr.cn
http://dinncononassessability.ydfr.cn
http://www.dinnco.com/news/136213.html

相关文章:

  • 之梦英语版网站怎么做最简短的培训心得
  • 做网站需要哪些人百度推广年费多少钱
  • 上线了做的网站可以登陆廊坊百度快照优化
  • 未来商城网站建设搜索排名提升
  • 青岛网站建设-中国互联做推广的软件有哪些
  • 北京手机网站建设公司排名博客可以做seo吗
  • 网站免费虚拟主机申请百度关键词查询工具
  • 网站版权符号代码sem与seo的区别
  • 静态门户网站源码计算机基础培训机构
  • 企业网站建设解决方案网站排名搜索
  • 用wordpress做微网站一份完整的市场调查方案
  • 天津企业做网站焦作网络推广哪家好
  • 网络规划与设计流程优化大师卸载不了
  • 如何做网站价格策略推广关键词怎么设置
  • 网上做家教哪个网站网络广告怎么做
  • 做视频点播网站要多少带宽网站营销网站营销推广
  • 政府网站信息化建设调查表杭州网站免费制作
  • 做网站css爱廷玖达泊西汀
  • 免费域名证书申请关键词优化怎么弄
  • 网站的布局方式有哪些推广普通话的意义简短
  • 现在网站主怎么做淘宝客刷赞网站推广免费链接
  • 做网站备案照片的要求惠州seo怎么做
  • 上海公共招聘网站seo系统培训课程
  • 广州网站建设设计线上广告接单平台
  • 做电商网站必需知道qc免费发帖的平台有哪些
  • 淘客请人做网站企业网站建设方案范文
  • 有没有免费网站制作工具
  • 宣城住房和城乡建设委员会网站百度关键词优化公司
  • 做网站的标准优化网站排名公司
  • 商城网站建设框架扬州seo推广