c#event^delegate, again

There are many excellent online introductions of the relationship between events and delegates. Here’s some personal observations —

1) first there’s a difference between an event-field vs an event occurrence (similar to tibrv event). When we say “This class has an event” or “subscribe to this eventA” we mean the field. However, when we say “fire this eventA” we use this big gun named eventA to fire a missile.

2) Virtually everyone commit the crime of ambiguity when they say a “delegate” rather than “a delegate Type” or “a delegate Instance”.

3) we must point out there are

  • delegate types
  • delegate instances
  • delegate variables — local variables, method parameters
  • a delegate field
    • ** a special case — If the delegate field has an “event” modifier, then the field becomes an event field.

It’s confusing and unproductive to compare event fields to delegate instances, or delegate types. Many casual discussions of event vs delegate often bring the delegate instances into the picture, adding to the confusion. Always remember this point whenever there is similarity/confusion between delegateInstance vs events.

An event field is better compared to a delegate variable, but an event field is BEST compared to a non-event delegate field. A non-event delegate field behaves differently from event fields. I think it’s supported and more flexible but rarely used. See
http://pro-thoughts.blogspot.sg/2008/08/delegates-and-events-what-does-event.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s