Internal working of delegates in C# [duplicate]
Possible Duplicate:
How delegates work (in the background)?
As we know delegate is function pointer.
How it is working internally?
Detailed explanation will be appreciated.
The following article on MSDN presents a nice overview of delegates in .NET and how they work internally.
Whilst I'm sure someone will come up with a good literal explanation for this, I'd recommend reading the following book which covers everything nicely:
http://www.amazon.com/dp/0735627045/ (CLR via C#, Jeffrey Richter).
Delegates (1) in C# are lists of method pointers. I.e. they store references to code, and you can invoke the methods via the pointers. This is useful in many cases. The common example is for event handlers where delegates are used to implement a publisher/subscriber pattern.
(1)
精彩评论