委托的简单例子



  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApplication1 {
  7. class Program {
  8. delegate double ProcessDelegate(double param1, double param2);
  9. static double Multiply(double param1, double param2) {
  10. return param1 * param2;
  11. }
  12. static double Divid(double param1, double param2) {
  13. return param1 / param2;
  14. }
  15. static void Main(string[] args) {
  16. ProcessDelegate process;
  17. double param1 = 200;
  18. double param2 = 300;
  19. process = new ProcessDelegate(Divid);
  20. double d = process(param1, param2);
  21. Console.WriteLine(d);
  22. }
  23. }
  24. }





posted @ 2017-01-28 17:32  xiejunzhao  阅读(170)  评论(0编辑  收藏  举报