static void Main(string[] args) { var e = new EventTest(5); e.SetValue(100); e.ChangeNum += new EventTest.NumManipulationHandler(EventTest.EventFired); e.SetValue(200); Console.ReadLine(); }
public static void Main() { EventTest e = new EventTest(); subscribEvent v = new subscribEvent(); e.ChangeNum += new EventTest.NumManipulationHandler(v.printf); e.SetValue(7); e.SetValue(11); }
static void Main(string[] args) { //EventHandler var e = new EventTest(5); e.SetValue(100); e.ChangeNum += new EventTest.NumManupulationHandler(EventTest.EventFired); e.SetValue(200); I i = new Myclass(); i.MyEvent += new MyDelegate(f); i.FireAway(); }
static void Main(string[] args) { var e = new EventTest(5); e.SetValue(10); e.ChangeNum += new EventTest.NumMainipulationHandler(EventTest.EventFired); e.SetValue(100); Console.WriteLine("------------------------"); I i = new MyClass(); i.MyEvent += new MyDelegate(f); i.FireAway(); Console.ReadLine(); }
static void Main(string[] args) { var e = new EventTest(5); e.SetValue(100); e.ChangeNum += new EventTest.NumManipulationHandler(EventTest.EventFired); //透過方法傳給委託然後綁定到event上面 e.SetValue(200); e.SetValue(100); e.SetValue(200); e.SetValue(100); I i = new MyClass(); i.MyEvent += new MyDelegate(f); i.FireAway(); Console.ReadLine(); }