委托 Delegate
什么是委托?
个人理解的话委托相当于C语言中的指针,也可以理解为它是一个类,百度的定义是
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Weituo_ShiJian { //定义一个委托 public delegate void AppearanceDelegate(string Appearance); class program { //定义一个方法 private static void Method(string Appearance) { Console.WriteLine("你的外貌非常:" + Appearance); } static void Main(string [] args) { //实例化委托并初始化 AppearanceDelegate appDelegate = new AppearanceDelegate(Method); Method("Handsome!"); Console.ReadKey(); } } }