c# - Simple Delegate (delegate) vs. Multicast delegates -
I have gone through several articles, but I am still not clear about the difference of general representatives who Generally create and multicast representatives.
Public representative Zero MyMethodHandler (object sender); MyMethodHandler handler = New MyMethodHandler (Method1); Handler + = Method 2; Handler (someObject);
The above representative MyMethodHandler will call these two methods, now where the multicast representatives come in. I have read that they can call many ways but I am afraid my basic understanding about the representatives is not correct.
It tells very well:
Representative Del ( String s); Class Test Class {Static Zero Halo (String) {System.Console.WriteLine ("Hello, {0}!", S); } Steady zero goodbye (strings) {System.Console.WriteLine ("Bye, {0}!", S); } Fixed Zero Main () {Del A, B, C, D; // rep refers to an object / method hello: a = hello; // Build the representative object b, reference / method method: b = bye; // Two reps, A and B, C: C = A + B are made in the form of; // Remove from the prepared representative, except D, which only says method bye: d = c - a; System.Console.WriteLine ("One representative invited:"); one A'); System.Console.WriteLine ("Invitation representative b:"); B ("b"); System.Console.WriteLine ("Invitation Representative c:"); C ("C"); System.Console.WriteLine ("Invitation representative d:"); watch'); }} / * Output: Invite Representative one: Hello, A! Inviting Representative: B. Goodbye, B! Invitation representative c: Hello, C! Goodbye, C! Delegate Representative D: Goodbye, D! * /
Comments
Post a Comment