标签:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 委托学习 { class Program { static void Main(string[] args) { Program p = new Program(); p.Greeting("谢峰", p.chineseGreeting); p.Greeting("sam", p.USGreeting); Console.ReadKey(); } //声明一个委托 public delegate void GreetingDelegate(string name); public void Greeting(string name, GreetingDelegate callback) { callback(name); } public void chineseGreeting(string name) { Console.WriteLine("你好,傻逼 "+name); } public void USGreeting(string name) { Console.WriteLine("hello,guy!"+" "+name); } } }
标签:
原文地址:http://www.cnblogs.com/xiefengdaxia123/p/5983014.html