field-like event syntax restrictions

— based on http://www.ikriv.com/en/prog/info/dotnet/Delegates.html
All events (Field-like or not) always support 2 operations += and -=. You can call them sub/unsub or add/remove.

An event is always a non-static Member of a class. IF compiler accepts your event as a field-like event, then it will accept 2 other operations on it
a) MyEvent != null or == null
b) MyEvent(….);

Internally, these were translated to refer to the hidden private Dlg field generated for every event.

Now, a couple of implications
! subclass can’t use (a) or (b) since the hidden field is private
! You may see (a/b) quite often, but if your event is not field-like, they won’t compile.

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