22. Delegates

xiaoxiao2021-04-05  279

[NOTE: DELEGATES ENABLE SCENARIOS THATHER 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 thing is deived 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 Appriate 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

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

Note]

转载请注明原文地址:https://www.9cbs.com/read-132007.html

New Post(0)