如何在c#中让变量每秒减1

如何在c#中让变量每秒减1


杨__羊羊
浏览 979回答 3
3回答

手掌心

12345678910111213141516171819202122    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();            Timer t = new Timer();            t.Interval = 1000;            t.Tick += T;//注册时钟事件            t.Enabled = true;        }         int n = 10000;         //时钟事件引发重绘        private void T(object o, EventArgs e)        {            n--;            //显示在标题中            Text = n.ToString();        }     } 

MYYA

#include <stdio.h>#include <time.h>int main( ){time_t nowtime;struct tm *t;int s;for(;;){time( &nowtime );t = localtime( &nowtime );if(s-t->int tm_sec>=1) 你要的变量--;}return 0;}
打开App,查看更多内容
随时随地看视频慕课网APP