Is it possible to add a literal code block as an event handler in C#? Something like:
Timer t = new Timer(1000);
t.Elapsed += new ElapsedEventHandler({ Console.WriteLine("Tick"); });
You can do this in PowerShell, so I thought there might be some way to do this in C# too.
You can use a lambda expression (C# 3.0 and higher):
or an anonymous method (C# 2.0 and higher):