如何使用时间跨度来倒计时分钟数?
How can I use timespan to count down minutes?
private void TimeToDownload(Label LabelToDisplay)
{
int _elapsedSeconds = 10;
System.Windows.Forms.Timer _timer = new System.Windows.Forms.Timer
{
Interval = 1000,
Enabled = true
};
_timer.Tick += (sender, args) =>
{
_elapsedSeconds--;
TimeSpan time = TimeSpan.FromMinutes(_elapsedSeconds);
LabelToDisplay.Text = time.ToString(@"mm\:ss");
};
}
分钟以秒为单位倒计时。
09:00 然后 08.00 然后 07.00 分钟倒计时为秒每秒一分钟倒计时,而不是用秒倒计时分钟。
您的 TimeSpan
已创建 FromMinutes
,而它应该是 FromSeconds
TimeSpan.FromSeconds(_elapsedSeconds);
private void TimeToDownload(Label LabelToDisplay)
{
int _elapsedSeconds = 10;
System.Windows.Forms.Timer _timer = new System.Windows.Forms.Timer
{
Interval = 1000,
Enabled = true
};
_timer.Tick += (sender, args) =>
{
_elapsedSeconds--;
TimeSpan time = TimeSpan.FromMinutes(_elapsedSeconds);
LabelToDisplay.Text = time.ToString(@"mm\:ss");
};
}
分钟以秒为单位倒计时。
09:00 然后 08.00 然后 07.00 分钟倒计时为秒每秒一分钟倒计时,而不是用秒倒计时分钟。
您的 TimeSpan
已创建 FromMinutes
,而它应该是 FromSeconds
TimeSpan.FromSeconds(_elapsedSeconds);