我一直在尝试将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