ASP.net: Code explanation of delegates and events
Given this code:
WriteThisMessageToThePage1.sendMessageToThePage += delegate(string message)
Can anyone explain me what this line means in delagates? W开发者_StackOverflow中文版hat does this code represent?
+= is a short hand notation for subscribing to an event. The delegate(string message)
code represents the event handler for the event. In this case the event handler is an anonymous method. When the sendMessageToThePage event fires, the code next += is executed.
精彩评论