剩餘秒我有一個問題。我想在倒數計時器中保存剩餘秒數(例如,剩餘時間= 12秒),我想在變量中保存12秒。 這是我的代碼保存在倒數計時器
int order = 0;
bool right = true;
DispatcherTimer timer1 = new DispatcherTimer();
private void timer_start()
{
timer1.Interval = new TimeSpan(0, 0, 0, 1);
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Start();
}
int remainingSecond;
int tik = 15;
void timer1_Tick(object sender, EventArgs e)
{
this.Timer.Text = tik.ToString();
if (tik > 0)
{
tik--;
if (this.order >= 5)
{
timer1.Stop();
if (right)
{
remainingSecond = tik;
}
else
remainingSecond = 0;
}
}
else
{
remainingSecond = 0;
timer1.Stop();
}
}
每次我寫「remainingSecond」,其值始終爲0。我希望remainingSecond
值爲12。幫助我,請。由於
寫入'TimeSpan.FromSeconds(1)',而不是'新的TimeSpan(0,0,0,1)'(創建1毫秒定時器)。 – 2013-02-24 06:41:33
我認爲'remainingSecond = tik'是錯誤的,但我不知道如何糾正它 – wahyudierwin 2013-02-24 06:48:49
感謝您的意見:D – wahyudierwin 2013-02-24 06:52:38