Console.WriteLine("请输入闹钟的日期时间"); DateTime s = Convert.ToDateTime(Console.ReadLine()); while (true) { Console.Clear(); Console.WriteLine(DateTime.Now.ToString("yyyy年MM月dd日 hh时mm分ss秒")); if (s.ToString("yyyyMMddhhmmss").Equals(DateTime.Now.ToString("yyyyMMddhhmmss"))) { Console.WriteLine("时间到了!\a\a\a\a\a\a\a\a\a\a\a..."); Console.WriteLine("是否要关闭闹钟,关闭请输入Y,否则请按N"); string c = Console.ReadLine(); if (c.ToUpper() == "Y") { break; } else if (c.ToUpper() == "N") { s = s.AddSeconds(59); //59秒后再响 } else { Console.WriteLine("输入错误!"); break; } } Thread.Sleep(1000); }