public void TestEvent() { EventDemo eventDemo = new EventDemo(); eventDemo.IAmTheEvent += eventDemoHandler; eventDemo.RaiseTheEvent(); }
public static void tryEvents() { MyEvent me = new MyEvent(); EventDemo ed = new EventDemo(); me.SomeEvent += (senders, e) => { Console.WriteLine("received: " + e.n); }; me.SomeEvent += ed.Handler; me.SomeEvent += delegate(object senders, MyEventArg e) { Console.WriteLine("received: " + (e.n + 2)); }; //this creates and method instead of pointing to a existing method. me.OnSomeEvent(1); }
static void Main(string[] args) { Program p = new Program(); // this is the delegate instantiation //Name.CompareFirstNames saticka funkcija //pokazuvac kon funkcija = delegate Comparer cmp = new Comparer(Name.CompareFirstNames); Console.WriteLine("==========Before sort==========="); p.PrintNames(); p.Sort(cmp); Console.WriteLine("==========After sort==========="); p.PrintNames(); Console.WriteLine("==========My delegate tesst==========="); //pointer declaration test t1 = new test(Name.PrintTest); //pointer call t1(); EventDemo eventd = new EventDemo(); //Application.EnableVisualStyles(); // Application.Run(new EventDemo()); Console.ReadKey(); }
public static void Main(string[] args) { EventDemo ed = new EventDemo(); ed.ClickButton(); }