为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

C#
杨__羊羊 2019-06-07 11:06:47
如何在c#中让变量每秒减1
查看完整描述

3 回答

?
手掌心

TA贡献1942条经验 获得超3个赞

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

    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();

        }

 

    }


 


查看完整回答
反对 回复 2019-06-08
?
MYYA

TA贡献1868条经验 获得超4个赞

#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;
}




查看完整回答
反对 回复 2019-06-08
  • 3 回答
  • 0 关注
  • 978 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信