在.NET事件签名模式模式、事件、NET

2023-09-03 13:26:32 作者:人丑个矮嘴巴不甜还没钱

什么是在标准模式在.NET事件委托的意义呢?即该事件处理程序predefined委托?为什么不选择最合适的签名要求?

What's the point in the standard pattern for event delegates in .net? I.e. the EventHandler predefined delegate? Why not just choose the most appropriate signature for the requirement?

编辑:,此外,是否有必要亦步亦趋地跟着微软的例子在所有情况下

And furthermore, is it necessary to slavishly follow Microsoft's example in all cases?

推荐答案

这是主要的一致性和版本,与发件人 paramater一如既往System.Object的和的args 参数一如既往一个System.EventArgs或dervied其类,你可以改变传递给它的寄件人参数以及改变EventArgs的类型后不会破坏任何现有的$ C $ ℃。

It's mainly for consistency and versioning—with the sender paramater as always System.Object and the args parameter as always a System.EventArgs, or a dervied class thereof, you can change the sender argument passed to it as well as change the EventArgs type afterwards without breaking any existing code.

整个.NET三项赛成语被设计为支持基于组件的开发,其中调用code是没有根据的部件与事件开发商的控制权。

The whole .NET eventing idiom was designed to support component-based development, where the calling code is not under control of the developer of the component with the events.