一、引入所需要的命名空间

using System.Diagnostics;

二、定义一个全局变量

private Stopwatch stw = new Stopwatch();

其中Stopwatch说明如下:

记录程序运行时间

三、在窗体载入时执行stw.Start代码如下

private void Form1_Load(object sender, EventArgs e) { stw.Start(); }

四、显示程序运行时间

MessageBox.Show(""+stw.Elapsed.Seconds.ToString());

相关文章:

  • 2021-11-29
  • 2018-06-18
  • 2021-12-11
  • 2021-07-28
  • 2022-12-23
  • 2022-02-06
  • 2021-09-05
  • 2022-12-23
猜你喜欢
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2021-12-24
相关资源
相似解决方案