22.2 Delegate Instantiation

xiaoxiao2021-04-05  238

An Instance of a Delegate Is CREATED BY a DELEGATE-CREATION-Expression (14.

5.10.3). The Newly Created Delegate

Instance the refers to each

? The static method referened in the delegate-credibility, or

? Target Object (Which cannot be null) and instance method referened in

The Delegate-CreationExpression,

oral

? Another delegate

[EXAMPLE: for EXAMPLE:

Delegate Void D (int X);

Class test

{

PUBLIC Static Void M1 (INT I) {?}

PUBLIC VOID M2 (INT I) {?}

}

Class Demo

{

Static void main () {

D CD1 = New D (Test.m1); // Static Method

Test T = New Test ();

D CD2 = New D (T.M2); // Instance Method

D CD3 = New D (CD2); // Another Delegate

}

}

End example]

Once Instantiated, Delegate Instances Always Refer to The Same Target

Object and method. [NOTE: Remember, When

Two Delegates Are Combined, or One Is Removed from Another, A New Delegate

Results with its oow infocation list;

The Invocation Lists of the Delegates Combined or Removed Remain Unchanged.

End Note]

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

New Post(0)