22. Delegates

原创 2006年06月22日 03:18:00
[Note: Delegates enable scenarios that other languages?such as C++, Pascal,
and Modula?have addressed with
function pointers. Unlike C++ function pointers, however, delegates are
fully object oriented, and unlike
C++ pointers to member functions, delegates encapsulate both an object
instance and a method. end note]
A delegate declaration defines a class that is derived from the class
System.Delegate. A delegate instance
encapsulates one or more methods, each of which is referred to as a
callable entity. For instance methods, a
callable entity consists of an instance and a method on that instance. For
static methods, a callable entity consists
of just a method. Given a delegate instance and an appropriate set of
arguments, one can invoke all of that
delegate instance?s methods with that set of arguments.
[Note: An interesting and useful property of a delegate instance is that it
does not know or care about the classes
of the methods it encapsulates; all that matters is that those methods be
compatible (§22.1) with the delegate?s
type. This makes delegates perfectly suited for ?anonymous? invocation. end

DOTNETc# 委托 delegates

首先来理解下委托的定义委托是一种引用方法的类型。也就是分配在一旦为委托分配栈中,委托将与该方法具有完全相同的行为。委托方法的使用可以像其他任何方法一样,具有参数和返回值,如下面的示例所示: C# pu...


原文链接:http://www.cnblogs.com/qiyer/p/4844564.html 有人问了我一个很棒的问题,我把这个问题总结为:“开发过程中该选择 blocks or d...

Creating and Using Your Own Delegates in Objective-C

I've been doing iPhone development for about a year now and have used the delegation pattern many ti...
  • gdmmhym
  • gdmmhym
  • 2011年09月01日 10:50
  • 251

C# events vs. delegates

We have looked at delegates and their implementation in two previous articles. But if you searched s...


转载至:http://www.cocoachina.com/ios/20150927/13525.html 原文链接:http://blog.stablekernel.com/blocks-or-de...
  • 2015年12月19日 21:50
  • 329


假设对象A调用B来执行一项操作,操作一旦完成,对象A就必须知道对象B已完成任务且对象A将执行其他必要操作。 在上面的示例中的关键概念有 A是B的委托对象 B引用一个A A将实现B的...


看了一篇大神总结的文章, 归纳出以下几点:       Apple声明方法时有很好的命名习惯(这也是我们精通iOS开发的一项必备技能)。例如:一个以NSString为参数的方法,方法的selecto...
  • longzs
  • longzs
  • 2015年09月25日 13:42
  • 320

Delegates and Events in C# / .NET

Content Overview Delegates Call a Function directly - No Delegate The very basic Delegate C...

Events and Delegates(事件和委托)

Introduction One of the most interesting concepts in C# is Event-Driven approach. Though it is a si...
您举报文章:22. Delegates