using System; using System.Threading; using System.Timers; using System.Collections; using System.Collections.Generic; namespace Consolehello { public delegate void callme(string s); class delegatetest { public event callme callmeyeah; public void callmeafter() { for(int i =0;i<=9;i++) { if (callmeyeah != null) { Thread.Sleep(1000); callmeyeah.Invoke("yes,it is" + i); } } } } class Program { static void Main(string[] args) { delegatetest t = new delegatetest(); t.callmeyeah += CallMeBaby; t.callmeafter(); Console.ReadKey(); } static void CallMeBaby(string s) { Console.WriteLine("call me baby one sec"+s); } } } (责任编辑:admin) |