2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace ConsoleApplication1
6 {
7 public delegate int DelegateClass(string info);
8 public class Program
9 {
10 public static void Main()
11 {
12 DelegateClass obj = new DelegateClass(MethodA);
13 DelegateClass obj2 = MethodA;
14 obj("1");
15 obj.Invoke("2");
16 obj = null;
17 obj2 = null;
18 }
19 public static int MethodA(string info)
20 {
21 Console.WriteLine("MethodA开始工作");
22 return int.Parse(info);
23 }
24 }
25}