今天就简单写个C#定时程序吧,比如到了7:33,就提示你该吃早饭的程序,代码如下:
string CurrTime; DateTime dt = DateTime.Now; CurrTime = dt.ToShortTimeString().ToString(); //获取系统时间 string s = "7:33 "; DateTime s1 = Convert.ToDateTime(s); DateTime s2 = Convert.ToDateTime(CurrTime); if (DateTime.Compare(s1, s2) ==0) { Console.Write("该吃早饭啦!!!"); }