[Note]CLR via C#3-Event and Delegate

I don't wanna talk about how those two features work. They are all important features of .Net Framework.

As we know, the event is a very special delegate, if you dig deeply and invesigate the code, you are gonna find the inside event  is implemented by event.

The event is on the top of delegate and  further encapsulated based on the delegate. and the delegate can do everthing that the event can do.

so the question is why we need the event, How 'special' the event is as opposed to the delegate,what the main difference is between them.

generally speaking, i think i got the point after some code and test:

The delegate is naked to the destination and the destination can do so many operations on it and also the distination can modify it while the event is further encapsulated based on the delegate and the destination can only listen to it. 

actually, the event is one of the important uses of the delegate. another one of important uses of it is the asychonous process with the BeginInvode and EndInvoce.

The relationship between those two and the Design Pattern

  • We can implement the Factory Design Pattern by using the delegate.
  • actually, the event is the Observer Pattern.


转载于:https://www.cnblogs.com/sanjia/archive/2011/09/01/2161477.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值