委托

 1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace 委托
7 {
8 class 委托
9 {
10 public delegate double delegateProd(int a);
11 public static double prodValues(int wall)
12 {
13 return wall+1;
14 }
15 static void Main(string[] args)
16 {
17
18 delegateProd delobj = new delegateProd(prodValues);//声明一个委托
19
20 Console.Write("please input number");
21 int var1 =int.Parse( Console.ReadLine());
22 double res = delobj(var1);//调用委托方法
23
24 Console.WriteLine("return number:{0}",res);
25 Console.ReadLine();
26 }
27 }
28 }
原文地址:https://www.cnblogs.com/mxxblog/p/2417731.html