什么时候在asp.net中使用代理? [英] When would I use a delegate in asp.net?

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

问题描述

我一直在寻找一种方法来使用我可以使用的所有工具,并将自己伸展到我所处的位置之外。但是,正如我已经看过的代表一样,我永远找不到一个使用它们的地方(如接口,泛型和很多东西,但我离题)我希望有人可以告诉我什么时候和如何使用代理在 web 编程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).

谢谢你,如果这是错误的Stack Overflow,请让我知道。

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.

要获得一个非常好的句柄关于这个问题和其中一些更先进和详细的方面,得到乔·达菲的书, .NET Framework 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天全站免登陆