May 2010
Intermediate to advanced
1752 pages
41h 17m
English
When you want to create a delegate type in C#, you use the delegate keyword. The name of your delegate type can be whatever you desire. However, you must define the delegate to match the signature of the method(s) it will point to. For example, assume you wish to build a delegate type named BinaryOp that can point to any method that returns an integer and takes two integers as input parameters:
// This delegate can point to any method, // taking two integers and returning an integer. public delegate int BinaryOp(int x, int y);
When the C# compiler processes delegate types, it automatically generates a sealed class deriving from System.MulticastDelegate. This class (in conjunction with its base class, System.Delegate ...