Skip to Content
.NET Common Language Runtime Unleashed
book

.NET Common Language Runtime Unleashed

by Kevin Burton
April 2002
Intermediate to advanced content levelIntermediate to advanced
1024 pages
23h 26m
English
Sams
Content preview from .NET Common Language Runtime Unleashed

Cloning delegates

delegates implement the ICloneable interface so that a delegate can be copied. The copy will be a deep copy so that each copy can exist independently, and changes to one will not affect changes in the other. Listing 14.19 shows a simple illustration. The full source for this code is in the DelegateClone directory.

Listing 14.19. Cloning delegates
 DelegateCallback ad = new DelegateCallback(ACallback); DelegateCallback bd = new DelegateCallback(BCallback); DelegateCallback cd = new DelegateCallback(CCallback); DelegateCallback dd = ad; dd += bd; dd += cd; DelegateCallback ed = dd; Console.WriteLine("Original list"); Delegate [] da = dd.GetInvocationList(); foreach(Delegate d in da) { Console.WriteLine("{0} {1} ", d.Target, d.Method); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Customizing the Microsoft® .NET Framework Common Language Runtime

Customizing the Microsoft® .NET Framework Common Language Runtime

Steven Pratschner

Publisher Resources

ISBN: 0672321246Purchase book