[Mono-dev] inherited event
David Mitchell
dmitchell at logos.com
Wed Feb 25 14:14:23 EST 2009
The reason that you cannot called inherited events is because the
syntax you use for OnBar is really syntactic sugar for something like this:
protected event OnBar
{
add { _onBar = Delegate.Combine(_onBar, value); }
remove { _onBar = Delegate.Remove(_onBar, value); }
}
private EventHandler _onBar;
Once you expand this, it¹s easy to see that you can¹t call _onBar in child
classes because it¹s private. In most cases, this really does make sense,
but if you want different behavior, you can either explicitly define OnBar
in this way and make _onBar protected (or whatever), or you can provide a
protected method (RaiseBar?) that raises the event if OnBar is not null.
--Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090225/e965b172/attachment.html
More information about the Mono-devel-list
mailing list