当我使用asp.net的委托? [英] When would I use a delegate in asp.net?

查看:110
本文介绍了当我使用asp.net的委托?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方式来使用所有的工具,我可以和舒展自己刚刚超越我在哪里。但是正如我所读到的代表,我永远无法找到使用它们的地方(如接口,泛型,和很多东西,但我离题了。)我希望有人能告诉我什么时候和他们是如何使用委托在的网站的编程asp.net C#(2.0以上)。

I'm always looking for a way to use all the tools I can and to stretch myself just beyond where I am at. But as much as I have read about delegates, I can never find a place to use them (like Interfaces, Generics, and a lot of stuff, but I digress.) I was hoping someone could show me when and how they used a delegate in web programming for asp.net c#(2.0 and above).

感谢你,如果这个错误的堆栈溢出,请让我知道。

Thank you and if this wrong for Stack Overflow, please just let me know.

推荐答案

bdukes是对有关事件。但是你不是只限于使用委托的事件。

bdukes is right about events. But you're not limited to just using delegates with events.

研究使用委托的更多例子经典的观察者模式。上的图案有些文本指出向着事件模型,但是从原料学习的角度,你不必使用事件。

Study the classic Observer Pattern for more examples on using delegates. Some text on the pattern points toward an event model, but from a raw learning perspective, you don't have to use events.

有一点要记住:一个代表就是,可以用来与放大器另一种类型;各地类似的原始类型通过如INT。就如同INT,一个代表都有它自己的特点,你可以在你消耗的委托类型在编码采取行动。

One thing to remember: A delegate is just another type that can be used & passed around similar to your primitive types such as an "int". And just like "int", a delegate has it's own special characteristics that you can act on in your coding when you consume the delegate type.

要在这个问题得到一个真正伟大的手柄和它的一些更先进,更细的方面,让Joe达菲的书, .NET框架2.0

To get a really great handle on the subject and on some of it's more advanced and detailed aspects, get Joe Duffy's book, .NET Framework 2.0.

这篇关于当我使用asp.net的委托?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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