private static void SixthEvolution() { // lambda EventGenerator gen = new EventGenerator(); gen.Fire += (sender, e) => Console.WriteLine("anonymous method handled the fire"); List <int> l = new List <int>(); var intGreaterThan0 = l.Where(delegate(int i) { return(i > 0); }); var intGreaterThan0Simple = l.Where(i => i > 0); Action <int> myAction = (i) => Console.WriteLine("arg is: " + i); myAction(80); Func <int, int> doubleIt = (val) => { int retval = val * val; return(retval); }; Console.WriteLine(doubleIt(5)); }
private static void FifthEvolution() { EventGenerator gen = new EventGenerator(); gen.Fire += delegate(object sender, EventArgs e) { Console.WriteLine("anonymous method handled the fire"); }; List <int> l = new List <int>(); }
private static void SecondEvolution() { // built in events EventGenerator firesEvents = new EventGenerator(); firesEvents.Fire += new EventHandler(HandleFire); for (int i = 0; i < 3; i++) { firesEvents.FiresEvents(); } }