Delegate is a type of secure encapsulation method, which is similar to function pointers in C and C ++. Unlike function pointers in C, delegation is object-oriented, type-safe, and insurance. The delegate type is defined by the delegate name. The following example declares a delegate named Del, which can encapsulate a method that uses strings as parameters and returns void. [Csharp] public delegate void Del (string message); when constructing a delegate object, the name of the delegate method to be wrapped or the anonymous method is usually provided. After the delegate is instantiated, the Delegate will pass the method calls to it to the method. The parameters passed by the caller to the delegate are passed to the method. The return values (if any) from the method are returned by the delegate to the caller. This is called a call delegate. An instantiated delegate can be called as the wrapped method itself. For example: [csharp] // Create a method for a delegate. public static void DelegateMethod (string message) {System. console. writeLine (message);} This example shows how to combine multicast delegates. A purpose of the delegate object is that you can use the + operator to assign them to a delegate instance to be a multicast delegate. The combination of the two delegates can be called. Only delegates of the same type can be combined. -Operators can be used to remove component delegation from the composite delegate. [Csharp] class Class1 {public delegate void PrintDelegate (string name, string id); public delegate void Del (int I); static void Main (string [] args) {Class1 obj = new Class1 (); PrintDelegate delegate1 = PrintStudent; PrintDelegate delegate2 = obj. printeBook; // + the object operated by the operator can only be a delegate object. // PrintDelegate multiDel = delegate1 + delegate2; // But + = the operation object on the right can be a method signature. // Simple multicast delegation. PrintDelegate multiDel = null; multiDel + = obj. printeBook; multiDel + = PrintStudent; multiDel ("test", "123"); Del d = delegate (int I) {Console. writeLine (++ I) ;}; d (10); Console. read ();}/*** both static and non-static methods can be used for delegation and signature methods. ** // Static method public static void PrintStudent (string name, string id) {www.2cto.com Console. writeLine ("student information"); Console. writeLine ("student id: {0}", id); Console. writeLine ("name: {0}", name) ;}// non-static method. Public void PrinteBook (string bookName, string code) {Console. writeLine ("books"); Console. writeLine ("No.:" + code); Console. writeLine ("name:" + bookName );}}