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(1010));
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 }

相关文章:

  • 2022-12-23
  • 2022-02-06
  • 2021-11-03
  • 2022-03-10
  • 2022-03-04
  • 2021-06-03
  • 2021-07-14
  • 2021-12-26
猜你喜欢
  • 2021-08-16
  • 2022-01-27
  • 2021-12-06
  • 2021-06-18
  • 2021-08-11
  • 2021-09-20
  • 2021-06-10
相关资源
相似解决方案