为什么要使用委托以及何时应该使用它。 [英] Why should use the delegate and when should use it.

查看:105
本文介绍了为什么要使用委托以及何时应该使用它。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一般来说,如果非静态方法在类中定义,我们可以使用类的对象调用方法,否则如果在类中定义静态方法,则使用类名调用方法。使用Delegate,我们可以调用方法,因为它有三个步骤(声明委托,创建委托对象,调用)。这是一个非常漫长的过程

但是为什么要使用Delegate而不是使用类的对象来调用方法

和何时应该使用代表更多,即哪种情况









请帮忙我。



谢谢你。



我尝试了什么: < br $>


为什么要使用Delegate而不是使用类

的对象调用方法,何时应该使用委托。

Generally we can invoke the method using object of the class if non static method define in class otherwise invoke the method using class name if static method define in class.using Delegate we can invoke the method it is very complex because three steps(declare delegate,create object of delegate,invoke).this is very long process
but why should use the Delegate rather than invoke the method using object of the class
and when should use the delegates more i.e which situation




please help me.

thank u.

What I have tried:

Why should use the Delegate rather than invoke the method using object of the class
and when should use the delegates.

推荐答案

阅读文档并成为Google的朋友:

Delega tes(C#编程指南) [ ^ ]

C# - 代表 [ ^ ]

如果你不明白你应该在哪里以及为什么要这样做使用它,那么你可能没有足够的经验或没有这种功能的要求。
Read the documentation and be friends with Google :
Delegates (C# Programming Guide)[^]
C# - Delegates[^]
If you don't understand where and why you should use it, then you are probably not experienced enough or don't have the requirements for this type of functionality.


这篇关于为什么要使用委托以及何时应该使用它。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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