帮助理解 .NET 委托、事件和事件处理程序 [英] Help understanding .NET delegates, events, and eventhandlers

查看:17
本文介绍了帮助理解 .NET 委托、事件和事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几天里,我问了几个关于代表的问题 这里这里.我承认......我不太了解代表.我真的真的真的很想了解和掌握它们.(我可以定义它们——类型安全函数指针——但由于我对 C 类型语言的经验很少,所以它并没有真正的帮助.)

In the last couple of days I asked a couple of questions about delegates HERE and HERE. I confess...I don't really understand delegates. And I REALLY REALLY REALLY want to understand and master them. (I can define them--type safe function pointers--but since I have little experience with C type languages it is not really helpful.)

任何人都可以推荐一些在线资源,这些资源将以一种不假设的方式解释代表吗?

Can anyone recommend some online resource(s) that will explain delegates in a way that presumes nothing?

这是我怀疑 VB 实际上妨碍了我的那些时刻之一,因为它在幕后为我做了一些连接.

This is one of those moments where I suspect that VB actually handicaps me because it does some wiring for me behind the scenes.

理想的资源只是解释什么是委托,而不参考其他任何东西(事件和事件处理程序),将向我展示所有一切是如何连接起来的,解释(正如我刚刚了解到的)委托是类型以及是什么使它们独特的类型(也许使用一点 ildasm 魔法)).然后,该基础将扩展以解释委托如何与事件和事件处理程序相关联,这本身就需要一个很好的解释.最后,该资源可以使用真实示例将它们联系在一起,并解释编译器会自动发生什么接线,如何使用它们等.哦,是的,什么时候应该和不应该使用委托,换句话说,缺点和替代方案使用代表.

The ideal resource would just explain what delegates are, without reference to anything else like (events and eventhandlers), would show me how all everything is wired up, explain (as I just learned) that delegates are types and what makes them unique as a type (perhaps using a little ildasm magic)). That foundation would then expand to explain how delegates are related to events and eventhandlers which would need a pretty good explanation in there own right. Finally this resource could tie it all together using real examples and explain what wiring DOES happen automatically by the compiler, how to use them, etc. And, oh yeah, when you should and should not use delegates, in other words, downsides and alternatives to using delegates.

你说什么?你们中的任何人都可以向我指出可以帮助我开始精通之旅的资源吗?

What say ye? Can any of you point me to resource(s) that can help me begin my journey to mastery?

编辑最后一件事.理想的资源将解释如何在接口声明中使用和不能使用委托.这真的让我很受挫.

EDIT One last thing. The ideal resource will explain how you can and cannot use delegates in an interface declaration. That is something that really tripped me up.

感谢您的帮助.

赛斯

推荐答案

我会从这些开始:

http://www.yoda.arachsys.com/csharp/events.html

http://msdn.microsoft.com/en-us/library/ms173171.aspx

这篇关于帮助理解 .NET 委托、事件和事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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