Friday, March 2, 2012

Anonymous Delegates

I thought a good place for Anonymous Delegates would be in dynamically created menu items that all do the same thing. This is also a good place for lambda expressions.


an interesting point


lets say I am adding a click event handler to a menu item
this is legal

ti2.Click +=  delegate { this.textBox1.Text = nav.Value; };
even though there are no arguments

this is not:
ti2.Click += () => { this.textBox1.Text = nav.Value; };

you need the input parameters

ti2.Click +=  (o,a  )=>{ this.textBox1.Text = nav.Value; };

No comments:

Post a Comment