Is it poor form for a C# class to subscribe to its own published events?

后端 未结 6 744
难免孤独
难免孤独 2020-12-16 17:06

I\'m probably just being neurotic, but I regularly find myself in situations in which I have class that publishes an event, and I find it convenient to subscribe to this eve

6条回答
  •  悲哀的现实
    2020-12-16 17:51

    I see no problem with this. But if you handle the events in the same class you could also override the event method:

    protected override void OnClick(Eventargs e)
    {
       base.OnClick(e);
    }
    

    This is more efficient and gives you the power to swallow the event if necessary (simply not calling base.OnClick()).

提交回复
热议问题