我一直在嘗試將timer
添加到我的代碼中,並且使用以下timespan
(小時,分鐘,秒)。但不明白爲什麼我保持以下錯誤:不能隱式地將類型'system.timespan'轉換爲雙倍
Cannot implicitly convert type 'System.timespan' to double.
這是我的代碼。
public static void Main(string[] args)
{
System.Timers.Timer MyTimer = new System.Timers.Timer();
MyTimer.Elapsed += new ElapsedEventHandler(onTimedEvent);
MyTimer.Interval = new TimeSpan(0,0,5000);
MyTimer.Enabled = true;
}
上面將運行而沒有任何問題,如果我設置Mytimer
間隔爲單個值如下。
Mytimer.Interval = 5000;
感謝@Igor現在做工精細的財產。 – JNW