在.NET事件签名模式 [英] Event signature pattern in .net

查看:131
本文介绍了在.NET事件签名模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是在标准模式在.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.

这篇关于在.NET事件签名模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆