將秒轉換成時間格式


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