![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace SimpleDelegate
6 {
7 public delegate int DelegateTest(int x,int y);
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 DelegateTest one = new DelegateTest(SimpleTest.Add);
13 Console.WriteLine("10+10={0}",one(10,10));
14 DelegateTest two = new DelegateTest(SimpleTest.Sub);
15 Console.WriteLine("10-10={0}", two(10, 10));
16 Console.ReadLine();
17 }
18 }
19 public class SimpleTest
20 {
21 public static int Add(int x,int y)
22 {
23 return x + y;
24 }
25 public static int Sub(int x, int y)
26 {
27 return x - y;
28 }
29 }
30 }
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace SimpleDelegate
6 {
7 public delegate int DelegateTest(int x,int y);
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 DelegateTest one = new DelegateTest(SimpleTest.Add);
13 Console.WriteLine("10+10={0}",one(10,10));
14 DelegateTest two = new DelegateTest(SimpleTest.Sub);
15 Console.WriteLine("10-10={0}", two(10, 10));
16 Console.ReadLine();
17 }
18 }
19 public class SimpleTest
20 {
21 public static int Add(int x,int y)
22 {
23 return x + y;
24 }
25 public static int Sub(int x, int y)
26 {
27 return x - y;
28 }
29 }
30 }