[Note]CLR via C#3-Event and Delegate
2011-09-01 00:14
344 查看
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.
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.
相关文章推荐
- [Note]CLR via C#3-Readonly and Const
- CLR Via C# 3rd 阅读摘要 -- Chapter 7 - Constants and Fileds
- [Note]CLR via C#3-Reflection:How to specify value to the private property
- [Note]CLR via C#3-Type Fundamentals
- 跟小静学CLR via C#(12)-委托Delegate
- The relation between event and delegate in visual c#
- Primitive, Reference, and Value Types(Chapter 5 of CLR via C#)
- CLR Via C# 3rd 阅读摘要 -- Chapter 3 - Shared Assemblies and Strongly Named Assemblies
- CLR Via C# 3rd 阅读摘要 -- Chapter 22 – CLR Hosting and AppDomains
- Shared Assemblies and Strongly Named Assemblies(Chapter 3 of CLR via C#)
- CLR Via C# 3rd 阅读摘要 -- Chapter 5 - Primitive, Reference, and Value Types
- C# delegate and event 续
- CLR Via C# 3rd 阅读摘要 -- Chapter 20 – Exceptions and State Management
- C# delegate and event
- C#编程利器之四:委托与事件(Delegate and event) (上)
- 委托和事件[delegate and event]_C#
- 委托和事件[delegate and event]_C#
- [Note]CLR via C#3-Metadata review
- .NET:CLR via C# Shared Assemblies and Strongly Named Assemblies
- [Note]CLR via C#3-Outline for Serialization