Jon said:
But in that case the original code would be broken in the same way, as
both handlers originally called OnBubbleClick.
Sorry, I don't really understand your reply. I didn't say anything was
broken, so I'm not sure what it means for something to "be broken in the
same way". In the same way as what?
I agree that with respect to the posted code, either you have two
different ObBubbleClick methods (overloaded) or a single one. But that
doesn't change the fact that you could in fact consolidate that logic
into a single method. In fact, trivially:
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
MonthChangedEventArgs mce = e as MonthChangedEventArgs;
if (mce != null)
{
OnBubbleClick(mce);
}
else
{
OnBubbleClick(e);
}
}
works fine as well (assuming OnBubbleClick is overloaded).
I don't intend to say that any of these methods is necessarily _better_,
simply that they also work and for the original question, which asked
simply whether a single event handler can be written, it's a correct
solution.
Nicholas wrote that the OP would "HAVE to deal with the lowest common
denominator" [emphasis mine], and it was to that which I was responding.
It may be true that alternatives to dealing with the lowest common
denominator have no real advantage to just having two event handling
methods in the first place, but that's not the same as saying it can't
be done.
Pete