event Action<> vs event EventHandler<>

后端 未结 7 2199
野的像风
野的像风 2020-11-28 02:05

Is there any different between declaring event Action<> and event EventHandler<>.

Assuming it doesn\'t matter what object actua

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 02:44

    The advantage of a wordier approach comes when your code is inside a 300,000 line project.

    Using the action, as you have, there is no way to tell me what bool, int, and Blah are. If your action passed an object that defined the parameters then ok.

    Using an EventHandler that wanted an EventArgs and if you would complete your DiagnosticsArgs example with getters for the properties that commented their purpose then you application would be more understandable. Also, please comment or fully name the arguments in the DiagnosticsArgs constructor.

提交回复
热议问题