今天就簡單寫個C#定時程序吧,好比到了7:33,就提示你該吃早飯的程序,代碼以下:spa
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("該吃早飯啦!!!"); }