先看一个简单的delegate的例子:

 1  public static bool IsOdd(int i)
 2         {
 3             return (i & 1== 1;
 4         }
 5         public delegate bool NumberTester(int i);
 6         public static void PrintMatchingNumbers(int from, int to, NumberTester filter)
 7         {
 8             for (int i = from; i <= to; ++i)
 9             {
10                 if (filter(i))
11                 {
12                     Console.WriteLine(i);
13                 }
14             }
15         }

相关文章:

  • 2021-09-19
  • 2021-05-23
  • 2021-09-18
  • 2022-01-23
  • 2021-06-10
  • 2022-01-06
猜你喜欢
  • 2022-01-24
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2021-04-29
相关资源
相似解决方案