Quote: Timer t = new Timer(); t.Elapsed += (sender, e) => elapse(sender, e, "Rahul"); t.Interval = 1000; t.Start();
Quote: t.Elapsed += (sender, e) => elapse(sender, e, "Rahul");
public static void elapse(object sender,ElapsedEventArgs e,string s) { Console.WriteLine("elapsed with :{0}",s); }
class Program { public delegate int MyDelegate(int a); static void Main(string[] args) { // public event ElapsedEventHandler Elapsed; //public delegate void ElapsedEventHandler(object sender, ElapsedEventArgs e); // Elapsed is an event handler of delegate ElapsedEventHandler // so we conclude that Elapsed is delegate // we can use lamda expression for delegates //A delegate is a type that represents references to methods with a particular parameter list and return type // in short , signature of the method ( return type and parameters ) MyDelegate m = (k) => Increament(k); var value = m.Invoke(23); } public static int Increament(int a) { return a++; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)