计时器问题 想做个计时器软件 就是 输入一个时间 然后开始倒计时 可是不知道怎么做 麻烦高手指点下! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 class Program { static void Main(string[] args) { //dt中存放你的时间,可以把需要的时间转换成一个秒数,这里设定为10秒 DateTime dt=new DateTime(10); long ticks = dt.Ticks; while (true) { System.Threading.Thread.Sleep(1000 * 1); if (ticks == 0) { break; } else { ticks--; } Console.WriteLine("test:" + ticks); } Console.WriteLine("game over"); Console.ReadLine(); } }拿控制台写的了! DateTime endTime;DateTime start;private void Form1_Load(object sender, EventArgs e) { endTime= DateTime.Now.AddSeconds(30); timer1.Enabled = true; } private void timer1_Tick(object sender, EventArgs e) { DateTime show = start.Subtract(new TimeSpan(DateTime.Now.Ticks)); label1.Text = show.ToLongTimeString(); } public partial class Form1 : Form { public Form1() { InitializeComponent(); } int x; private void Form1_Load(object sender, EventArgs e) { this.timer1.Interval = 1000; } private void button1_Click(object sender, EventArgs e) { timer1.Start(); x = int.Parse(textBox1.Text.Trim()); } private void timer1_Tick(object sender, EventArgs e) { try { x--; label1.Text = x.ToString(); if (x < 1) { this.timer1.Stop(); } } catch (Exception ex) { MessageBox.Show("输入整数"); } } } javascript 脚本能调用C#后台代码么?如何调用? 求教大大们一个TabControl的tabpage切换的问题 C# 更新当前记录问题,有代码,帮忙看看,谢谢! Visual Studio Add-in的加载问题,顶也有分 解释: 在页面检索完成之前,请求超时。代码:10060 关于SqldataReader的问题 求助——help,如何更新cookie啊 如何用installshield11.5打.msi的包? 为什么我在vs2012里建不了数据库 XML绑定web下的treeview后,显示中文的问题 报点希望问问~~~希望能有答案 最大能上传多大文件到csdn 里
class Program
{
static void Main(string[] args)
{
//dt中存放你的时间,可以把需要的时间转换成一个秒数,这里设定为10秒
DateTime dt=new DateTime(10);
long ticks = dt.Ticks; while (true)
{
System.Threading.Thread.Sleep(1000 * 1);
if (ticks == 0)
{
break;
}
else
{
ticks--;
}
Console.WriteLine("test:" + ticks);
}
Console.WriteLine("game over");
Console.ReadLine();
}
}
拿控制台写的了!
DateTime start;private void Form1_Load(object sender, EventArgs e)
{
endTime= DateTime.Now.AddSeconds(30);
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
DateTime show = start.Subtract(new TimeSpan(DateTime.Now.Ticks));
label1.Text = show.ToLongTimeString();
}
{
public Form1()
{
InitializeComponent();
}
int x;
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Interval = 1000;
} private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
x = int.Parse(textBox1.Text.Trim());
} private void timer1_Tick(object sender, EventArgs e)
{
try
{
x--;
label1.Text = x.ToString();
if (x < 1)
{
this.timer1.Stop();
} }
catch (Exception ex)
{
MessageBox.Show("输入整数");
}
} }