【发布时间】:2015-11-17 14:28:18
【问题描述】:
好的,所以我想做的是倒计时结束时,这意味着达到我在 2 天内将其放入的 endTime,我想重置并再增加 7 天,并尽可能继续这样做。我试过使用
if(endTime.Subtract(DateTime.Now) = 0)
{
}
但这给了我一个错误“赋值的左侧必须是变量、属性或索引器”,并且还使用 .ToString() 方法将 ts 转换为字符串,但这仍然不起作用!所有代码均取自here 我想在那里发表评论,但我是新用户。在此先感谢您,我想我已经涵盖了所有内容,请在投反对票之前提出任何要求!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TV_Series_New_Episodes
{
public partial class Flash : Form
{
DateTime endTime = new DateTime(2015, 11 ,19, 14 ,30, 0);
public Flash()
{
InitializeComponent();
}
private void ct_Tick(object sender, EventArgs e)
{
TimeSpan ts = endTime.Subtract(DateTime.Now);
ctlb.Text = ts.ToString("d' Days 'h' Hours 'm' Minutes 's' Seconds'");
if(endTime.Subtract(DateTime.Now) = 0)
{
}
}
private void Flash_Load(object sender, EventArgs e)
{
ct.Interval= 500;
ct.Tick += new EventHandler(ct_Tick);
TimeSpan ts = endTime.Subtract(DateTime.Now);
ctlb.Text = ts.ToString("d' Days 'h' Hours 'm' Minutes 's' Seconds'");
ct.Start();
}
}
}
【问题讨论】:
标签: c# datetime countdown timespan