//5.注冊事件處理程序
public Host(Dog dog)
{
dog.Alarm += new Dog.AlarmEventHandler(HostHandleAlarm);
}
}
//6.現在來觸發事件
class Program
{
static void Main(string[] args)
{
Dog dog = new Dog();
Host host = new Host(dog);
//當前時間,從2008年12月31日23:59:50開 始計時
DateTime now = new DateTime(2008,12,31,23,59,50);
DateTime midnight = new DateTime(2009, 1, 1, 0, 0, 0);
//等待午夜的到 來
Console.WriteLine("時間一秒一秒地流逝...");
while (now < midnight)
{
Console.WriteLine("當 前