Custom EventHandler vs. EventHandler

前端 未结 2 1213
萌比男神i
萌比男神i 2021-01-30 12:48

Recently I\'ve been wondering if there is any significant difference between this code:

public event EventHandler SomeEvent;

2条回答
  •  萌比男神i
    2021-01-30 13:05

    The second way gives more flexibility and type safety. There are less methods with corresponding signature => less place for a mistake. Custom delegate allows to specify exactly parameters you need (or specify no one) - no sender+args cargo cult.

提交回复
热议问题