Thursday, 23 February 2012

Lambda Action / Delegate

Common Delegate Call
 b.Click += delegate(object sender, EventArgs e) 
                    { 
                      Log("Sender :" + sender + "EventArgs " + e);  
                    };
Same as
Using Lambda 
1. Call Action with Parameter
  (o, e) => {
             // Statements  
          }
2. Call Action Without Parameter
  () => { // Statements }
3. Implement Action
Public void ImplementAction(Action a){ a(); }
4. Create Object
string className = "MyClass";
 var obj = (T) Activator.CreateInstance(Type.GetType(className));

No comments:

Post a Comment