by Miha Markič
28. August 2007 15:46
Can you guess how many times will this console application output the current date?
class Program
{
private static Tubo tubo = new Tubo();
static void Main(string[] args)
{
One();
tubo.RaiseTubek();
Console.WriteLine("Finished");
Console.ReadLine();
}
private static void One()
{
tubo.Tubek += delegate { Console.WriteLine(DateTime.Now); };
tubo.RaiseTubek();
}
}
public class Tubo
{
public event EventHandler Tubek;
public void RaiseTubek()
{
if (Tubek != null)
Tubek(this, EventArgs.Empty);
}
}
4f74f84f-0c76-4fa0-b93f-4debdb619f61|0|.0
Tags:
.net