public void ShowTime() { int nowh = DateTime.Now.Hour; int nowm = DateTime.Now.Minute; Console.Clear(); Console.Write($"当前时间:{DateTime.Now.ToShortTimeString().ToString()}"); while (DateTime.Now.Hour != hour || DateTime.Now.Minute != minute) { if (nowh != DateTime.Now.Hour || nowm != DateTime.Now.Minute) { nowh = DateTime.Now.Hour; nowm = DateTime.Now.Minute; Console.Clear(); Console.Write($"当前时间:{DateTime.Now.ToShortTimeString().ToString()}"); } } Console.WriteLine(); RingEventArgs e = new RingEventArgs(); e.hour = hour; e.minute = minute; Ring(this, e); }
public void Ring(object sender, RingEventArgs e) { Console.WriteLine($"已到达设置时间{e.hour}:{e.minute}"); }