event Action<> vs event EventHandler<>

后端 未结 7 2251
野的像风
野的像风 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:32

    The main difference will be that if you use Action<> your event will not follow the design pattern of virtually any other event in the system, which I would consider a drawback.

    One upside with the dominating design pattern (apart from the power of sameness) is that you can extend the EventArgs object with new properties without altering the signature of the event. This would still be possible if you used Action, but I don't really see the point with not using the regular approach in that case.

提交回复
热议问题