namespace ConsoleApplication3
{
class huidiao
{
#region 无返回值函数
public delegate void dele();
public void huidiao_v(dele cal) //必须是public
{
Console.WriteLine("我是一个委托函数");
}
public huidiao(dele cal)
{
cal();
}
#endregion
}
class cheshi
{
public void huidiao_func()
{
Console.WriteLine("我是一个回调函数");
}
}
class Program
{
public static void huidiao_func() //静态才可以用
{
Console.WriteLine("我是一个回调函数");
}
static void Main(string[] args)
{
cheshi c = new cheshi();
huidiao th = new huidiao(huidiao_func);
Console.ReadKey();
}
}
非常基础的回调原理解析,希望能帮助到没吃透回调函数和委托的你
线程thread就是应用该原理,再加上几个触发方法