委托简单例子
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class test : System.Web.UI.Page { public delegate string Delegate(string name); protected void Page_Load(object sender, EventArgs e) { Label1.Text = People("小明", English); Label2.Text = People("小阳", Chinese); } private static string English(string name) { return "Morning," + name; } private static string Chinese(string name) { return "早上好, " + name; } //注意此方法,它接受一个GreetingDelegate类型的参数,该参数是返回值为空,参数为string类型的方法 private static string People(string name, Delegate Make) { return Make(name); } }