将秒转换成时间格式


Stopwatch Timer 时间 计时器 ElapsedMilliseconds

22


   /// <summary>
        /// 转换成时间 00:00:00
        /// </summary>
        /// <param name="duration"></param>
        /// <returns></returns>
        public string time(long duration)
        {
            TimeSpan t = new TimeSpan(0, 0, Convert.ToInt32(duration));
            //string str = "00:00:00";
            return   $"{t.Hours:00}:{t.Minutes:00}:{t.Seconds : 00}";
        }

        int t = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            t++;
            label4.Text =$"时间:{time(t)}";
        }


(sw.ElapsedMilliseconds / 1000f).ToString("0.000 sec")


文档:Stopwatch Timer 时间 计时器 ElapsedM...
链接: http://note.youdao.com/noteshare?id=ae1178e78b2c5c09a19fd22da60b452c


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM