An event simply adds a layer of protection over a delegate instance.
This protection prevents clients of the delegate from resetting the delegate and its invocation list, and only allows adding or removing targets from the invocation list.
Source: http://weblogs.asp.net/rosherove/archive/2004/03/28/100444.aspx
An esteemed colleague directed me to a post (can't recall) that further elaborates on the distinction. The main one that I remember is that in addition to the = restriction, invocations of an Event are restricted to the class that owns the event.
So if you want to allow other classes to raise an event you must expose a public method to that delegates the raising.
Subscribe to:
Post Comments (Atom)
C# Sucks!
JK!! Seriously, though, somewhere around C#-3 we should have inculcated ourselves with the question: "Does 'CAN' == 'SHOULD...
-
That pesky problem has reared its ugly head again! I remembered that its a permissions problem but forgot the wrinkle where you have to REMO...
-
Today I learned that it is possible to call private and protected methods by using reflection. This is a great technique for Unit Testing su...
No comments:
Post a Comment